From e83bcc1050ab250aaeaa2c31371028a74509e14d Mon Sep 17 00:00:00 2001 From: Shamim Rezaie Date: Thu, 3 Dec 2015 17:58:21 +1100 Subject: [PATCH] MDL-52380 mod_forum: Non-Gregorian dates in forum advance search Convert the fromdate and todate date parts to Gregorian before passing them to make_timestamp --- lib/moodlelib.php | 2 +- mod/forum/search.php | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/moodlelib.php b/lib/moodlelib.php index c26d8c6815b..e9598eb71ca 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -2026,7 +2026,7 @@ function get_user_preferences($name = null, $default = null, $user = null) { // FUNCTIONS FOR HANDLING TIME. /** - * Given date parts in user time produce a GMT timestamp. + * Given Gregorian date parts in user time produce a GMT timestamp. * * @package core * @category time diff --git a/mod/forum/search.php b/mod/forum/search.php index 7784eb0daad..046ffa68451 100644 --- a/mod/forum/search.php +++ b/mod/forum/search.php @@ -46,7 +46,9 @@ $fromyear = optional_param('fromyear', 0, PARAM_INT); // Starting date $fromhour = optional_param('fromhour', 0, PARAM_INT); // Starting date $fromminute = optional_param('fromminute', 0, PARAM_INT); // Starting date if ($timefromrestrict) { - $datefrom = make_timestamp($fromyear, $frommonth, $fromday, $fromhour, $fromminute); + $calendartype = \core_calendar\type_factory::get_calendar_instance(); + $gregorianfrom = $calendartype->convert_to_gregorian($fromyear, $frommonth, $fromday); + $datefrom = make_timestamp($gregorianfrom['year'], $gregorianfrom['month'], $gregorianfrom['day'], $fromhour, $fromminute); } else { $datefrom = optional_param('datefrom', 0, PARAM_INT); // Starting date } @@ -58,7 +60,9 @@ $toyear = optional_param('toyear', 0, PARAM_INT); // Ending date $tohour = optional_param('tohour', 0, PARAM_INT); // Ending date $tominute = optional_param('tominute', 0, PARAM_INT); // Ending date if ($timetorestrict) { - $dateto = make_timestamp($toyear, $tomonth, $today, $tohour, $tominute); + $calendartype = \core_calendar\type_factory::get_calendar_instance(); + $gregorianto = $calendartype->convert_to_gregorian($toyear, $tomonth, $today); + $dateto = make_timestamp($gregorianto['year'], $gregorianto['month'], $gregorianto['day'], $tohour, $tominute); } else { $dateto = optional_param('dateto', 0, PARAM_INT); // Ending date } -- 2.43.0