From 33998d30eaf920f75c6606f749ece1ffc3813b35 Mon Sep 17 00:00:00 2001 From: stronk7 Date: Thu, 3 Apr 2008 18:09:15 +0000 Subject: [PATCH] Fixed DST calculation when requesting explicit (parameter) timezones. MDL-14093 ; merged from 19_STABLE --- lib/moodlelib.php | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/lib/moodlelib.php b/lib/moodlelib.php index 8ed6f03463..f4857630a5 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -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 -- 2.39.5