function _signup_date_sql_handler in Signup 5.2
Same name and namespace in other branches
- 6.2 includes/date.inc \_signup_date_sql_handler()
Generate a DateAPI SQL handler for the given CCK date field.
This can be removed once revision 1.39.2.48 of date/date.module is widely available in an official release.
2 calls to _signup_date_sql_handler()
- _signup_date_autoclose_sql in includes/
date.5x-2.inc - _signup_date_reminder_sql in includes/
date.5x-2.inc
File
- includes/
date.5x-2.inc, line 197 - Code required to support version 5.x-2.* of the CCK date field module.
Code
function _signup_date_sql_handler($field, $compare_tz = NULL) {
// Workaround for a bug in DateAPI upto 6.x-2.0-rc5.
static $mysql_db_offset_set = FALSE;
require_once drupal_get_path('module', 'date_api') . '/date_api_sql.inc';
// Create a DateAPI SQL handler class for this field type.
$handler = new date_sql_handler();
$handler
->construct($field['type']);
// If this date field stores a timezone in the DB, tell the handler about it.
if ($field['tz_handling'] == 'date') {
// The field has a date column
$handler->db_timezone_field = $field['database']['columns']['timezone']['column'];
}
else {
$handler->db_timezone = date_get_timezone_db($field['tz_handling']);
}
if (empty($compare_tz)) {
$compare_tz = date_get_timezone($field['tz_handling']);
}
$handler->local_timezone = $compare_tz;
// Now that the handler is properly initialized, tell the DB what TZ to use.
$handler
->set_db_timezone();
// Up to and including DateAPI 5.x-2.4, the previous call only worked
// for mysqli and pgsql. It was a no-op on mysql itself, so in that case, we
// have to do the work ourselves here or datestamp fields don't work.
if ($GLOBALS['db_type'] == 'mysql' && !$mysql_db_offset_set && version_compare(db_version(), '4.1.3', '>=')) {
db_query("SET @@session.time_zone = '+00:00'");
$mysql_db_offset_set = TRUE;
}
return $handler;
}