From c075a3de344f08c41de69ad8a42070457854c667 Mon Sep 17 00:00:00 2001 From: Andrew Nicols Date: Wed, 19 Jul 2017 09:37:14 +0800 Subject: [PATCH] MDL-59388 calendar: Add a helper to convert ymd to timestamp --- calendar/classes/type_base.php | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/calendar/classes/type_base.php b/calendar/classes/type_base.php index a7d52fe2f57..a211be15806 100644 --- a/calendar/classes/type_base.php +++ b/calendar/classes/type_base.php @@ -217,4 +217,26 @@ abstract class type_base { * @return string locale */ public abstract function locale_win_charset(); + + /** + * Provided with a day, month, year, hour and minute in the specific + * calendar type convert it into the equivalent Unix Time Stamp. + * + * @param int $year + * @param int $month + * @param int $day + * @param int $hour + * @param int $minute + * @return int timestamp + */ + public function convert_to_timestamp($year, $month, $day, $hour = 0, $minute = 0) { + $gregorianinfo = $this->convert_to_gregorian($year, $month, $day, $hour, $minute); + return make_timestamp( + $gregorianinfo['year'], + $gregorianinfo['month'], + $gregorianinfo['day'], + $gregorianinfo['hour'], + $gregorianinfo['minute'], + 0); + } } -- 2.43.0