From b0213770d2d8d6892042288da35f0ec17e849258 Mon Sep 17 00:00:00 2001 From: Damyon Wiese Date: Tue, 2 Apr 2019 13:59:37 +0800 Subject: [PATCH] MDL-65243 badges: Use real time api Never add or subtract timestamps - use the time api to do it correctly. --- lib/badgeslib.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/badgeslib.php b/lib/badgeslib.php index 986e503f80e..53de1c8d18d 100644 --- a/lib/badgeslib.php +++ b/lib/badgeslib.php @@ -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; }