You are here

function date_sql_handler::db_tz_support in Date 5.2

Same name and namespace in other branches
  1. 6.2 date_api_sql.inc \date_sql_handler::db_tz_support()
  2. 6 date_api_sql.inc \date_sql_handler::db_tz_support()
  3. 7.3 date_api/date_api_sql.inc \date_sql_handler::db_tz_support()
  4. 7 date_api/date_api_sql.inc \date_sql_handler::db_tz_support()
  5. 7.2 date_api/date_api_sql.inc \date_sql_handler::db_tz_support()

See if the db has timezone name support.

1 call to date_sql_handler::db_tz_support()
date_sql_handler::sql_tz in ./date_api_sql.inc
Select a date value from the database, adjusting the value for the timezone.

File

./date_api_sql.inc, line 62

Class

date_sql_handler
A class to manipulate date SQL.

Code

function db_tz_support($reset = FALSE) {
  $has_support = variable_get('date_db_tz_support', -1);
  if ($has_support == -1 || $reset) {
    date_api_set_db_timezone();
    $has_support = FALSE;
    switch ($this->db_type) {
      case 'mysql':
      case 'mysqli':
        if (version_compare(db_version(), '4.1.3', '>=')) {
          $test = db_result(db_query("SELECT CONVERT_TZ('2008-02-15 12:00:00', 'UTC', 'US/Central')"));
          if ($test == '2008-02-15 06:00:00') {
            $has_support = TRUE;
          }
        }
        break;
      case 'pgsql':
        $test = db_result(db_query("'2008-02-15 12:00:00 UTC' AT TIME ZONE 'US/Central'"));
        if ($test == '2008-02-15 06:00:00') {
          $has_support = TRUE;
        }
        break;
    }
    variable_set('date_db_tz_support', $has_support);
  }
  return $has_support;
}