mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 08:26:37 +02:00
Fixed DST calculation when requesting explicit (parameter) timezones. MDL-14093 ; merged from 19_STABLE
This commit is contained in:
parent
c6ad17f74b
commit
33998d30ea
1 changed files with 14 additions and 9 deletions
|
@ -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) {
|
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);
|
$timezone = get_user_timezone_offset($timezone);
|
||||||
|
|
||||||
if (abs($timezone) > 13) {
|
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 = gmmktime((int)$hour, (int)$minute, (int)$second, (int)$month, (int)$day, (int)$year);
|
||||||
$time = usertime($time, $timezone);
|
$time = usertime($time, $timezone);
|
||||||
if($applydst) {
|
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;
|
global $CFG;
|
||||||
|
|
||||||
|
$strtimezone = NULL;
|
||||||
|
if (!is_numeric($timezone)) {
|
||||||
|
$strtimezone = $timezone;
|
||||||
|
}
|
||||||
|
|
||||||
if (empty($format)) {
|
if (empty($format)) {
|
||||||
$format = get_string('strftimedaydatetime');
|
$format = get_string('strftimedaydatetime');
|
||||||
}
|
}
|
||||||
|
@ -1183,7 +1193,7 @@ function userdate($date, $format='', $timezone=99, $fixday = true) {
|
||||||
$fixday = ($formatnoday != $format);
|
$fixday = ($formatnoday != $format);
|
||||||
}
|
}
|
||||||
|
|
||||||
$date += dst_offset_on($date);
|
$date += dst_offset_on($date, $strtimezone);
|
||||||
|
|
||||||
$timezone = get_user_timezone_offset($timezone);
|
$timezone = get_user_timezone_offset($timezone);
|
||||||
|
|
||||||
|
@ -1293,7 +1303,6 @@ function usertime($date, $timezone=99) {
|
||||||
*/
|
*/
|
||||||
function usergetmidnight($date, $timezone=99) {
|
function usergetmidnight($date, $timezone=99) {
|
||||||
|
|
||||||
$timezone = get_user_timezone_offset($timezone);
|
|
||||||
$userdate = usergetdate($date, $timezone);
|
$userdate = usergetdate($date, $timezone);
|
||||||
|
|
||||||
// Time of midnight of this user's day, in GMT
|
// Time of midnight of this user's day, in GMT
|
||||||
|
@ -1407,7 +1416,7 @@ function get_user_timezone($tz = 99) {
|
||||||
|
|
||||||
$tz = 99;
|
$tz = 99;
|
||||||
|
|
||||||
while(($tz == '' || $tz == 99) && $next = each($timezones)) {
|
while(($tz == '' || $tz == 99 || $tz == NULL) && $next = each($timezones)) {
|
||||||
$tz = $next['value'];
|
$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) {
|
function calculate_user_dst_table($from_year = NULL, $to_year = NULL, $strtimezone = NULL) {
|
||||||
global $CFG, $SESSION;
|
global $CFG, $SESSION;
|
||||||
|
|
||||||
if ($strtimezone == NULL) {
|
$usertz = get_user_timezone($strtimezone);
|
||||||
$usertz = get_user_timezone();
|
|
||||||
} else {
|
|
||||||
$usertz = $strtimezone;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (is_float($usertz)) {
|
if (is_float($usertz)) {
|
||||||
// Trivial timezone, no DST
|
// Trivial timezone, no DST
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue