Skip to content

Commit

Permalink
MDL-52380 mod_forum: Non-Gregorian dates in forum advance search
Browse files Browse the repository at this point in the history
Convert the fromdate and todate date parts to Gregorian before passing them to make_timestamp
  • Loading branch information
rezaies authored and junpataleta committed Dec 18, 2015
1 parent d607b84 commit 8abf370
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/moodlelib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 6 additions & 2 deletions mod/forum/search.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@
$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
}
Expand All @@ -58,7 +60,9 @@
$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
}
Expand Down

0 comments on commit 8abf370

Please sign in to comment.