1 date.views.inc date_views_set_timezone(&$date_handler, &$view, $field)

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.

File

core/modules/date/views/date.views.inc, line 122
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;
  }
}