mirror of
https://github.com/moodle/moodle.git
synced 2025-04-15 21:45:37 +02:00
MDL-58596 core_stats: fixed infinite loop cause by DST change
This commit is contained in:
parent
5007d1cb04
commit
8f402dbc66
@ -987,18 +987,24 @@ function stats_get_base_daily($time=0) {
|
||||
function stats_get_base_weekly($time=0) {
|
||||
global $CFG;
|
||||
|
||||
$time = stats_get_base_daily($time);
|
||||
$datetime = new DateTime();
|
||||
$datetime->setTimestamp(stats_get_base_daily($time));
|
||||
$startday = $CFG->calendar_startwday;
|
||||
|
||||
core_date::set_default_server_timezone();
|
||||
$thisday = date('w', $time);
|
||||
|
||||
$days = 0;
|
||||
|
||||
if ($thisday > $startday) {
|
||||
$time = $time - (($thisday - $startday) * 60*60*24);
|
||||
$days = $thisday - $startday;
|
||||
} else if ($thisday < $startday) {
|
||||
$time = $time - ((7 + $thisday - $startday) * 60*60*24);
|
||||
$days = 7 + $thisday - $startday;
|
||||
}
|
||||
return $time;
|
||||
|
||||
$datetime->sub(new DateInterval("P{$days}D"));
|
||||
|
||||
return $datetime->getTimestamp();
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user