MDL-22183 lib: Cleanup of get_next functions.

This commit is contained in:
Adrian Greeve 2016-08-09 11:18:40 +08:00
parent 4ae0691169
commit 3cdc35b44d

View File

@ -1024,13 +1024,10 @@ function stats_get_base_monthly($time=0) {
*/
function stats_get_next_day_start($time) {
$next = stats_get_base_daily($time);
$next = $next + 60*60*26;
$next = stats_get_base_daily($next);
if ($next <= $time) {
//DST trouble - prevent infinite loops
$next = $next + 60*60*24;
}
return $next;
$nextdate = new DateTime();
$nextdate->setTimestamp($next);
$nextdate->add(new DateInterval('P1D'));
return $nextdate->getTimestamp();
}
/**
@ -1040,13 +1037,10 @@ function stats_get_next_day_start($time) {
*/
function stats_get_next_week_start($time) {
$next = stats_get_base_weekly($time);
$next = $next + 60*60*24*9;
$next = stats_get_base_weekly($next);
if ($next <= $time) {
//DST trouble - prevent infinite loops
$next = $next + 60*60*24*7;
}
return $next;
$nextdate = new DateTime();
$nextdate->setTimestamp($next);
$nextdate->add(new DateInterval('P1W'));
return $nextdate->getTimestamp();
}
/**
@ -1056,13 +1050,10 @@ function stats_get_next_week_start($time) {
*/
function stats_get_next_month_start($time) {
$next = stats_get_base_monthly($time);
$next = $next + 60*60*24*33;
$next = stats_get_base_monthly($next);
if ($next <= $time) {
//DST trouble - prevent infinite loops
$next = $next + 60*60*24*31;
}
return $next;
$nextdate = new DateTime();
$nextdate->setTimestamp($next);
$nextdate->add(new DateInterval('P1M'));
return $nextdate->getTimestamp();
}
/**