mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 08:56:36 +02:00
MDL-58596 core_stats: fixed infinite loop cause by DST change
This commit is contained in:
parent
5007d1cb04
commit
8f402dbc66
1 changed files with 10 additions and 4 deletions
|
@ -987,18 +987,24 @@ function stats_get_base_daily($time=0) {
|
||||||
function stats_get_base_weekly($time=0) {
|
function stats_get_base_weekly($time=0) {
|
||||||
global $CFG;
|
global $CFG;
|
||||||
|
|
||||||
$time = stats_get_base_daily($time);
|
$datetime = new DateTime();
|
||||||
|
$datetime->setTimestamp(stats_get_base_daily($time));
|
||||||
$startday = $CFG->calendar_startwday;
|
$startday = $CFG->calendar_startwday;
|
||||||
|
|
||||||
core_date::set_default_server_timezone();
|
core_date::set_default_server_timezone();
|
||||||
$thisday = date('w', $time);
|
$thisday = date('w', $time);
|
||||||
|
|
||||||
|
$days = 0;
|
||||||
|
|
||||||
if ($thisday > $startday) {
|
if ($thisday > $startday) {
|
||||||
$time = $time - (($thisday - $startday) * 60*60*24);
|
$days = $thisday - $startday;
|
||||||
} else if ($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…
Add table
Add a link
Reference in a new issue