You are here

function user_timezone in Date 6

Same name and namespace in other branches
  1. 5.2 date_timezone/date_timezone.module \user_timezone()
  2. 6.2 date_timezone/date_timezone.module \user_timezone()

Menu callback; Retrieve a JSON object containing a suggested time zone name.

1 string reference to 'user_timezone'
date_timezone_menu in date_timezone/date_timezone.module
Implementation of hook_menu().

File

date_timezone/date_timezone.module, line 167
This module will make the alter the user and site timezone forms to select a timezone name instead of a timezone offset.

Code

function user_timezone($abbreviation = '', $offset = -1, $is_daylight_saving_time = NULL) {

  // An abbreviation of "0" passed in the callback arguments should be
  // interpreted as the empty string.
  $abbreviation = $abbreviation ? $abbreviation : '';
  $timezone = timezone_name_from_abbr($abbreviation, intval($offset), $is_daylight_saving_time);

  // The client date is passed in for debugging purposes.
  $date = isset($_GET['date']) ? $_GET['date'] : '';

  // Log a debug message.
  watchdog('timezone', 'Detected time zone: %timezone; client date: %date; abbreviation: %abbreviation; offset: %offset; daylight saving time: %is_daylight_saving_time.', array(
    '%timezone' => $timezone,
    '%date' => $date,
    '%abbreviation' => $abbreviation,
    '%offset' => $offset,
    '%is_daylight_saving_time' => $is_daylight_saving_time,
  ));
  drupal_json($timezone);
}