You are here

function date_sql_handler::db_tz_support in Date 7

Same name and namespace in other branches
  1. 5.2 date_api_sql.inc \date_sql_handler::db_tz_support()
  2. 6.2 date_api_sql.inc \date_sql_handler::db_tz_support()
  3. 6 date_api_sql.inc \date_sql_handler::db_tz_support()
  4. 7.3 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/date_api_sql.inc
Select a date value from the database, adjusting the value for the timezone.

File

date_api/date_api_sql.inc, line 87
SQL helper for Date API.

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':
        $test = db_query("SELECT CONVERT_TZ('2008-02-15 12:00:00', 'UTC', 'US/Central')")
          ->fetchField();
        if ($test == '2008-02-15 06:00:00') {
          $has_support = TRUE;
        }
        break;
      case 'pgsql':
        $test = db_query("SELECT '2008-02-15 12:00:00 UTC' AT TIME ZONE 'US/Central'")
          ->fetchField();
        if ($test == '2008-02-15 06:00:00') {
          $has_support = TRUE;
        }
        break;
    }
    variable_set('date_db_tz_support', $has_support);
  }
  return $has_support;
}