Download & Extend

Incorrect handling of Timezones

Project:Scheduler
Version:7.x-1.x-dev
Component:Code
Category:bug report
Priority:critical
Assigned:Unassigned
Status:closed (fixed)

Issue Summary

The current timezone handling code in scheduler is not correct because it does not use drupal 7 timezones/dst.

scheduler.module:466-485, this function is called in scheduler_node_presave before insert/update to retrieve the publish_on time

function _scheduler_strtotime($str) {
  if ($str && trim($str) != "" ) {
    $date_format = variable_get('scheduler_date_format', SCHEDULER_DATE_FORMAT);

    if (_scheduler_use_date_popup()) {
      $date_format = SCHEDULER_DATE_FORMAT;
    }
    $time = _scheduler_strptime(trim($str), $date_format);
    if ($time !== FALSE) {
      // success
      $time -= _scheduler_get_user_timezone();
    }
  }
  else {
    // $str is empty
    $time = NULL;
  }

  return $time;
}

scheduler.module:558-564

function _scheduler_get_user_timezone() {
  global $user;
  $timezone = variable_get('date_default_timezone', 0);
  if ((variable_get('configurable_timezones', 1) == 1) && (strlen($user->timezone))) {
    $timezone = $user->timezone;
  }
  return $timezone;
}

As you can see scheduler is handling the timezone part itself. In _scheduler_strtotime() the user/default timezone is -= form the $time. The function however returns a string like 'Europe/Amsterdam' and not an actual time. There is also a drupal function for this available but that also returns the string timezone:
http://api.drupal.org/api/drupal/includes--bootstrap.inc/function/drupal...

So correcting the $time with the user timezone is not working anymore. Instead Drupal 7 now sets the timezone/dst in the bootstrap. There for I think the proper solution will be to change _scheduler_strptime() to use mktime() instead of gmmktime(). Please review.

Comments

#1

AttachmentSize
1064638.patch 1.57 KB

#2

Title:Inproper handling of Timezones» Incorrect handling of Timezones

#3

Status:needs review» fixed

My prayers have been answered!! Drupal finally got sane time zone/DST handling! ;-)

http://drupal.org/cvs?commit=501650

Thanks a lot!

#4

Status:fixed» closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

nobody click here