You are here

function date_views_set_timezone in Date 7

Same name and namespace in other branches
  1. 8 date_views/includes/date_views.views.inc \date_views_set_timezone()
  2. 5.2 date/date_views.inc \date_views_set_timezone()
  3. 6.2 includes/date_api.views.inc \date_views_set_timezone()
  4. 7.3 date_views/includes/date_views.views.inc \date_views_set_timezone()
  5. 7.2 date_views/includes/date_views.views.inc \date_views_set_timezone()

Central function for setting up the right timezone values in the SQL date handler.

The date handler will use this information to decide if the database value needs a timezone conversion.

In Views, we will always be comparing to a local date value, so the goal is to convert the database value to the right value to compare to the local value.

1 call to date_views_set_timezone()
date_views_argument_handler::get_query_fields in date_views/includes/date_views_argument_handler.inc

File

date_views/includes/date_views.views.inc, line 153
Defines date-related Views data and plugins:

Code

function date_views_set_timezone(&$date_handler, &$view, $field) {
  switch ($field['tz_handling']) {
    case 'date':
      $date_handler->db_timezone = 'UTC';
      $date_handler->local_timezone_field = $field['timezone_field'];
      $date_handler->offset_field = $field['offset_field'];
      break;
    case 'none':
      $date_handler->db_timezone = date_default_timezone();
      $date_handler->local_timezone = date_default_timezone();
      break;
    case 'utc':
      $date_handler->db_timezone = 'UTC';
      $date_handler->local_timezone = 'UTC';
      break;
    default:
      $date_handler->db_timezone = 'UTC';
      $date_handler->local_timezone = date_default_timezone();
      break;
  }
}