]> git.mjollnir.org Git - moodle.git/commitdiff
Fixed DST calculation when requesting explicit (parameter) timezones. MDL-14093 ...
authorstronk7 <stronk7>
Thu, 3 Apr 2008 18:09:15 +0000 (18:09 +0000)
committerstronk7 <stronk7>
Thu, 3 Apr 2008 18:09:15 +0000 (18:09 +0000)
lib/moodlelib.php

index 8ed6f03463fb2c14b3ad8061f73bb3963d6bd3e6..f4857630a502749690b383a3ca031a307213887d 100644 (file)
@@ -1068,6 +1068,11 @@ function get_user_preferences($name=NULL, $default=NULL, $otheruserid=NULL) {
  */
 function make_timestamp($year, $month=1, $day=1, $hour=0, $minute=0, $second=0, $timezone=99, $applydst=true) {
 
+    $strtimezone = NULL;
+    if (!is_numeric($timezone)) {
+        $strtimezone = $timezone;
+    }
+
     $timezone = get_user_timezone_offset($timezone);
 
     if (abs($timezone) > 13) {
@@ -1076,7 +1081,7 @@ function make_timestamp($year, $month=1, $day=1, $hour=0, $minute=0, $second=0,
         $time = gmmktime((int)$hour, (int)$minute, (int)$second, (int)$month, (int)$day, (int)$year);
         $time = usertime($time, $timezone);
         if($applydst) {
-            $time -= dst_offset_on($time);
+            $time -= dst_offset_on($time, $strtimezone);
         }
     }
 
@@ -1172,6 +1177,11 @@ function userdate($date, $format='', $timezone=99, $fixday = true) {
 
     global $CFG;
 
+    $strtimezone = NULL;
+    if (!is_numeric($timezone)) {
+        $strtimezone = $timezone;
+    }
+
     if (empty($format)) {
         $format = get_string('strftimedaydatetime');
     }
@@ -1183,7 +1193,7 @@ function userdate($date, $format='', $timezone=99, $fixday = true) {
         $fixday = ($formatnoday != $format);
     }
 
-    $date += dst_offset_on($date);
+    $date += dst_offset_on($date, $strtimezone);
 
     $timezone = get_user_timezone_offset($timezone);
 
@@ -1293,7 +1303,6 @@ function usertime($date, $timezone=99) {
  */
 function usergetmidnight($date, $timezone=99) {
 
-    $timezone = get_user_timezone_offset($timezone);
     $userdate = usergetdate($date, $timezone);
 
     // Time of midnight of this user's day, in GMT
@@ -1407,7 +1416,7 @@ function get_user_timezone($tz = 99) {
 
     $tz = 99;
 
-    while(($tz == '' || $tz == 99) && $next = each($timezones)) {
+    while(($tz == '' || $tz == 99 || $tz == NULL) && $next = each($timezones)) {
         $tz = $next['value'];
     }
 
@@ -1450,11 +1459,7 @@ function get_timezone_record($timezonename) {
 function calculate_user_dst_table($from_year = NULL, $to_year = NULL, $strtimezone = NULL) {
     global $CFG, $SESSION;
 
-    if ($strtimezone == NULL) {
-        $usertz = get_user_timezone();
-    } else {
-        $usertz = $strtimezone;
-    }
+    $usertz = get_user_timezone($strtimezone);
 
     if (is_float($usertz)) {
         // Trivial timezone, no DST