MDL-65243 badges: Use real time api

Never add or subtract timestamps - use the time api to do it correctly.
This commit is contained in:
Damyon Wiese
2019-10-09 11:55:22 +08:00
committed by Mihail Geshoski
parent 8b89ab5798
commit 93d309cce2
+6 -3
View File
@@ -233,13 +233,16 @@ function badges_calculate_message_schedule($schedule) {
switch ($schedule) {
case BADGE_MESSAGE_DAILY:
$nextcron = time() + 60 * 60 * 24;
$tomorrow = new DateTime("1 day", core_date::get_server_timezone_object());
$nextcron = $tomorrow->getTimestamp();
break;
case BADGE_MESSAGE_WEEKLY:
$nextcron = time() + 60 * 60 * 24 * 7;
$nextweek = new DateTime("1 week", core_date::get_server_timezone_object());
$nextcron = $nextweek->getTimestamp();
break;
case BADGE_MESSAGE_MONTHLY:
$nextcron = time() + 60 * 60 * 24 * 7 * 30;
$nextmonth = new DateTime("1 month", core_date::get_server_timezone_object());
$nextcron = $nextmonth->getTimestamp();
break;
}