MDL-60125 calendar: Switch to navigation by YMD

This commit is contained in:
Andrew Nicols 2017-09-14 11:05:17 +08:00
parent 91cbdda6af
commit f58424c70c
12 changed files with 234 additions and 82 deletions

View File

@ -1 +1 @@
define(["jquery","core/ajax"],function(a,b){var c=function(a){var c={methodname:"core_calendar_delete_calendar_events",args:{events:[{eventid:a,repeat:1}]}};return b.call([c])[0]},d=function(a){var c={methodname:"core_calendar_get_calendar_event_by_id",args:{eventid:a}};return b.call([c])[0]},e=function(a){var c={methodname:"core_calendar_submit_create_update_form",args:{formdata:a}};return b.call([c])[0]},f=function(a,c){var d={methodname:"core_calendar_get_calendar_monthly_view",args:{time:a,courseid:c}};return b.call([d])[0]},g=function(a,c){var d={methodname:"core_calendar_update_event_start_day",args:{eventid:a,daytimestamp:c}};return b.call([d])[0]};return{getEventById:d,deleteEvent:c,updateEventStartDay:g,submitCreateUpdateForm:e,getCalendarMonthData:f}});
define(["jquery","core/ajax"],function(a,b){var c=function(a){var c={methodname:"core_calendar_delete_calendar_events",args:{events:[{eventid:a,repeat:1}]}};return b.call([c])[0]},d=function(a){var c={methodname:"core_calendar_get_calendar_event_by_id",args:{eventid:a}};return b.call([c])[0]},e=function(a){var c={methodname:"core_calendar_submit_create_update_form",args:{formdata:a}};return b.call([c])[0]},f=function(a,c,d){var e={methodname:"core_calendar_get_calendar_monthly_view",args:{year:a,month:c,courseid:d}};return b.call([e])[0]},g=function(a,c){var d={methodname:"core_calendar_update_event_start_day",args:{eventid:a,daytimestamp:c}};return b.call([d])[0]};return{getEventById:d,deleteEvent:c,updateEventStartDay:g,submitCreateUpdateForm:e,getCalendarMonthData:f}});

View File

@ -1 +1 @@
define(["jquery","core/templates","core/notification","core_calendar/repository","core_calendar/events"],function(a,b,c,d,e){var f={ROOT:"[data-region='calendar']",CALENDAR_NAV_LINK:".calendarwrapper .arrow_link",CALENDAR_MONTH_WRAPPER:".calendarwrapper",LOADING_ICON_CONTAINER:'[data-region="overlay-icon-container"]'},g=function(b){b=a(b),b.on("click",f.CALENDAR_NAV_LINK,function(c){var d=a(b).find(f.CALENDAR_MONTH_WRAPPER).data("courseid"),e=a(c.currentTarget);i(b,e.attr("href"),e.data("time"),d),c.preventDefault()})},h=function(g,h,i){return k(g),d.getCalendarMonthData(h,i).then(function(a){return b.render(g.attr("data-template"),a)}).then(function(a,c){return b.replaceNode(g.find(f.CALENDAR_MONTH_WRAPPER),a,c)}).then(function(){a("body").trigger(e.viewUpdated)}).always(function(){return l(g)}).fail(c.exception)},i=function(b,c,d,f){return h(b,d,f).then(function(){return c.length&&"#"!==c&&window.history.pushState({},"",c),arguments}).then(function(){return a("body").trigger(e.monthChanged,[d,f]),arguments})},j=function(a,b){var c=a.find(f.CALENDAR_MONTH_WRAPPER).data("current-time");return b||(b=a.find(f.CALENDAR_MONTH_WRAPPER).data("courseid")),h(a,c,b)},k=function(a){var b=a.find(f.LOADING_ICON_CONTAINER);b.removeClass("hidden")},l=function(a){var b=a.find(f.LOADING_ICON_CONTAINER);b.addClass("hidden")};return{init:function(a){g(a)},reloadCurrentMonth:j,changeMonth:i,refreshMonthContent:h}});
define(["jquery","core/templates","core/notification","core_calendar/repository","core_calendar/events"],function(a,b,c,d,e){var f={ROOT:"[data-region='calendar']",CALENDAR_NAV_LINK:".calendarwrapper .arrow_link",CALENDAR_MONTH_WRAPPER:".calendarwrapper",LOADING_ICON_CONTAINER:'[data-region="overlay-icon-container"]'},g=function(b){b=a(b),b.on("click",f.CALENDAR_NAV_LINK,function(c){var d=a(b).find(f.CALENDAR_MONTH_WRAPPER).data("courseid"),e=a(c.currentTarget);i(b,e.attr("href"),e.data("year"),e.data("month"),d),c.preventDefault()})},h=function(g,h,i,j){return k(g),d.getCalendarMonthData(h,i,j).then(function(a){return b.render(g.attr("data-template"),a)}).then(function(a,c){return b.replaceNode(g.find(f.CALENDAR_MONTH_WRAPPER),a,c)}).then(function(){a("body").trigger(e.viewUpdated)}).always(function(){return l(g)}).fail(c.exception)},i=function(b,c,d,f,g){return h(b,d,f,g).then(function(){return c.length&&"#"!==c&&window.history.pushState({},"",c),arguments}).then(function(){return a("body").trigger(e.monthChanged,[d,f,g]),arguments})},j=function(a,b){var c=a.find(f.CALENDAR_MONTH_WRAPPER).data("year"),d=a.find(f.CALENDAR_MONTH_WRAPPER).data("month");return b||(b=a.find(f.CALENDAR_MONTH_WRAPPER).data("courseid")),h(a,c,d,b)},k=function(a){var b=a.find(f.LOADING_ICON_CONTAINER);b.removeClass("hidden")},l=function(a){var b=a.find(f.LOADING_ICON_CONTAINER);b.addClass("hidden")};return{init:function(a){g(a)},reloadCurrentMonth:j,changeMonth:i,refreshMonthContent:h}});

View File

@ -87,16 +87,18 @@ define(['jquery', 'core/ajax'], function($, Ajax) {
* Get calendar data for the month view.
*
* @method getCalendarMonthData
* @param {Number} time Timestamp.
* @param {Number} year Year
* @param {Number} month Month
* @param {Number} courseid The course id.
* @return {promise} Resolved with the month view data.
*/
var getCalendarMonthData = function(time, courseid) {
var getCalendarMonthData = function(year, month, courseid) {
var request = {
methodname: 'core_calendar_get_calendar_monthly_view',
args: {
time: time,
courseid: courseid
year: year,
month: month,
courseid: courseid,
}
};

View File

@ -42,7 +42,7 @@ define(['jquery', 'core/templates', 'core/notification', 'core_calendar/reposito
root.on('click', SELECTORS.CALENDAR_NAV_LINK, function(e) {
var courseId = $(root).find(SELECTORS.CALENDAR_MONTH_WRAPPER).data('courseid');
var link = $(e.currentTarget);
changeMonth(root, link.attr('href'), link.data('time'), courseId);
changeMonth(root, link.attr('href'), link.data('year'), link.data('month'), courseId);
e.preventDefault();
});
@ -51,14 +51,16 @@ define(['jquery', 'core/templates', 'core/notification', 'core_calendar/reposito
/**
* Refresh the month content.
*
* @param {Number} time The calendar time to be shown
* @param {object} root The root element.
* @param {Number} year Year
* @param {Number} month Month
* @param {Number} courseid The id of the course whose events are shown
* @return {promise}
*/
var refreshMonthContent = function(root, time, courseid) {
var refreshMonthContent = function(root, year, month, courseid) {
startLoading(root);
return CalendarRepository.getCalendarMonthData(time, courseid)
return CalendarRepository.getCalendarMonthData(year, month, courseid)
.then(function(context) {
return Templates.render(root.attr('data-template'), context);
})
@ -78,13 +80,15 @@ define(['jquery', 'core/templates', 'core/notification', 'core_calendar/reposito
/**
* Handle changes to the current calendar view.
*
* @param {object} root The root element.
* @param {String} url The calendar url to be shown
* @param {Number} time The calendar time to be shown
* @param {Number} year Year
* @param {Number} month Month
* @param {Number} courseid The id of the course whose events are shown
* @return {promise}
*/
var changeMonth = function(root, url, time, courseid) {
return refreshMonthContent(root, time, courseid)
var changeMonth = function(root, url, year, month, courseid) {
return refreshMonthContent(root, year, month, courseid)
.then(function() {
if (url.length && url !== '#') {
window.history.pushState({}, '', url);
@ -92,7 +96,7 @@ define(['jquery', 'core/templates', 'core/notification', 'core_calendar/reposito
return arguments;
})
.then(function() {
$('body').trigger(CalendarEvents.monthChanged, [time, courseid]);
$('body').trigger(CalendarEvents.monthChanged, [year, month, courseid]);
return arguments;
});
};
@ -105,12 +109,13 @@ define(['jquery', 'core/templates', 'core/notification', 'core_calendar/reposito
* @return {promise}
*/
var reloadCurrentMonth = function(root, courseId) {
var time = root.find(SELECTORS.CALENDAR_MONTH_WRAPPER).data('current-time');
var year = root.find(SELECTORS.CALENDAR_MONTH_WRAPPER).data('year');
var month = root.find(SELECTORS.CALENDAR_MONTH_WRAPPER).data('month');
if (!courseId) {
courseId = root.find(SELECTORS.CALENDAR_MONTH_WRAPPER).data('courseid');
}
return refreshMonthContent(root, time, courseId);
return refreshMonthContent(root, year, month, courseId);
};
/**

View File

@ -0,0 +1,92 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Class for normalising the date data.
*
* @package core_calendar
* @copyright 2017 Andrew Nicols <andrew@nicols.co.uk>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core_calendar\external;
defined('MOODLE_INTERNAL') || die();
use core\external\exporter;
use renderer_base;
use moodle_url;
/**
* Class for normalising the date data.
*
* @package core_calendar
* @copyright 2017 Andrew Nicols <andrew@nicols.co.uk>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class date_exporter extends exporter {
/**
* Constructor for date_exporter.
*
* @param array $data
* @param array $related The related information
*/
public function __construct($data, $related = []) {
$data['timestamp'] = $data[0];
unset($data[0]);
parent::__construct($data, $related);
}
protected static function define_properties() {
return [
'seconds' => [
'type' => PARAM_INT,
],
'minutes' => [
'type' => PARAM_INT,
],
'hours' => [
'type' => PARAM_INT,
],
'mday' => [
'type' => PARAM_INT,
],
'wday' => [
'type' => PARAM_INT,
],
'mon' => [
'type' => PARAM_INT,
],
'year' => [
'type' => PARAM_INT,
],
'yday' => [
'type' => PARAM_INT,
],
'weekday' => [
'type' => PARAM_RAW,
],
'month' => [
'type' => PARAM_RAW,
],
'timestamp' => [
'type' => PARAM_INT,
],
];
}
}

View File

@ -104,9 +104,6 @@ class month_exporter extends exporter {
'filter_selector' => [
'type' => PARAM_RAW,
],
'navigation' => [
'type' => PARAM_RAW,
],
'weeks' => [
'type' => week_exporter::read_properties_definition(),
'multiple' => true,
@ -118,8 +115,8 @@ class month_exporter extends exporter {
'view' => [
'type' => PARAM_ALPHA,
],
'time' => [
'type' => PARAM_INT,
'date' => [
'type' => date_exporter::read_properties_definition(),
],
'periodname' => [
// Note: We must use RAW here because the calendar type returns the formatted month name based on a
@ -127,7 +124,10 @@ class month_exporter extends exporter {
'type' => PARAM_RAW,
],
'previousperiod' => [
'type' => PARAM_INT,
'type' => date_exporter::read_properties_definition(),
],
'previousperiodlink' => [
'type' => PARAM_URL,
],
'previousperiodname' => [
// Note: We must use RAW here because the calendar type returns the formatted month name based on a
@ -135,13 +135,16 @@ class month_exporter extends exporter {
'type' => PARAM_RAW,
],
'nextperiod' => [
'type' => PARAM_INT,
'type' => date_exporter::read_properties_definition(),
],
'nextperiodname' => [
// Note: We must use RAW here because the calendar type returns the formatted month name based on a
// calendar format.
'type' => PARAM_RAW,
],
'nextperiodlink' => [
'type' => PARAM_URL,
],
'larrow' => [
// The left arrow defined by the theme.
'type' => PARAM_RAW,
@ -160,22 +163,30 @@ class month_exporter extends exporter {
* @return array Keys are the property names, values are their values.
*/
protected function get_other_values(renderer_base $output) {
$previousperiod = $this->get_previous_month_timestamp();
$nextperiod = $this->get_next_month_timestamp();
$previousperiod = $this->get_previous_month_data();
$nextperiod = $this->get_next_month_data();
$date = $this->related['type']->timestamp_to_date_array($this->calendar->time);
$nextperiodlink = new moodle_url($this->url);
$nextperiodlink->param('time', $nextperiod[0]);
$previousperiodlink = new moodle_url($this->url);
$previousperiodlink->param('time', $previousperiod[0]);
return [
'courseid' => $this->calendar->courseid,
'filter_selector' => $this->get_course_filter_selector($output),
'navigation' => $this->get_navigation($output),
'weeks' => $this->get_weeks($output),
'daynames' => $this->get_day_names($output),
'view' => 'month',
'time' => $this->calendar->time,
'date' => (new date_exporter($date))->export($output),
'periodname' => userdate($this->calendar->time, get_string('strftimemonthyear')),
'previousperiod' => $previousperiod,
'previousperiodname' => userdate($previousperiod, get_string('strftimemonthyear')),
'nextperiod' => $nextperiod,
'nextperiodname' => userdate($nextperiod, get_string('strftimemonthyear')),
'previousperiod' => (new date_exporter($previousperiod))->export($output),
'previousperiodname' => userdate($previousperiod[0], get_string('strftimemonthyear')),
'previousperiodlink' => $previousperiodlink->out(false),
'nextperiod' => (new date_exporter($nextperiod))->export($output),
'nextperiodname' => userdate($nextperiod[0], get_string('strftimemonthyear')),
'nextperiodlink' => $nextperiodlink->out(false),
'larrow' => $output->larrow(),
'rarrow' => $output->rarrow(),
];
@ -197,19 +208,6 @@ class month_exporter extends exporter {
return $content;
}
/**
* Get the calendar navigation controls.
*
* @param renderer_base $output
* @return string The html code to the calendar top navigation.
*/
protected function get_navigation(renderer_base $output) {
return calendar_top_controls('month', [
'id' => $this->calendar->courseid,
'time' => $this->calendar->time,
]);
}
/**
* Get the list of day names for display, re-ordered from the first day
* of the week.
@ -302,17 +300,30 @@ class month_exporter extends exporter {
];
}
/**
* Get the current month timestamp.
*
* @return int The month timestamp.
*/
protected function get_month_data() {
$date = $this->related['type']->timestamp_to_date_array($this->calendar->time);
$monthtime = $this->related['type']->convert_to_gregorian($date['year'], $date['month'], 1);
return make_timestamp($monthtime['year'], $monthtime['month']);
}
/**
* Get the previous month timestamp.
*
* @return int The previous month timestamp.
*/
protected function get_previous_month_timestamp() {
$date = $this->related['type']->timestamp_to_date_array($this->calendar->time);
$month = calendar_sub_month($date['mon'], $date['year']);
$monthtime = $this->related['type']->convert_to_gregorian($month[1], $month[0], 1);
protected function get_previous_month_data() {
$type = $this->related['type'];
$date = $type->timestamp_to_date_array($this->calendar->time);
list($date['mon'], $date['year']) = $type->get_prev_month($date['year'], $date['mon']);
$time = $type->convert_to_timestamp($date['year'], $date['mon'], 1);
return make_timestamp($monthtime['year'], $monthtime['month'], $monthtime['day'], $monthtime['hour'], $monthtime['minute']);
return $type->timestamp_to_date_array($time);
}
/**
@ -320,11 +331,12 @@ class month_exporter extends exporter {
*
* @return int The next month timestamp.
*/
protected function get_next_month_timestamp() {
$date = $this->related['type']->timestamp_to_date_array($this->calendar->time);
$month = calendar_add_month($date['mon'], $date['year']);
$monthtime = $this->related['type']->convert_to_gregorian($month[1], $month[0], 1);
protected function get_next_month_data() {
$type = $this->related['type'];
$date = $type->timestamp_to_date_array($this->calendar->time);
list($date['mon'], $date['year']) = $type->get_next_month($date['year'], $date['mon']);
$time = $type->convert_to_timestamp($date['year'], $date['mon'], 1);
return make_timestamp($monthtime['year'], $monthtime['month'], $monthtime['day'], $monthtime['hour'], $monthtime['minute']);
return $type->timestamp_to_date_array($time);
}
}

View File

@ -879,17 +879,19 @@ class core_calendar_external extends external_api {
/**
* Get data for the monthly calendar view.
*
* @param int $time The time to be shown
* @param int $year The year to be shown
* @param int $month The month to be shown
* @param int $courseid The course to be included
* @return array
*/
public static function get_calendar_monthly_view($time, $courseid) {
public static function get_calendar_monthly_view($year, $month, $courseid) {
global $CFG, $DB, $USER, $PAGE;
require_once($CFG->dirroot."/calendar/lib.php");
// Parameter validation.
$params = self::validate_parameters(self::get_calendar_monthly_view_parameters(), [
'time' => $time,
'year' => $year,
'month' => $month,
'courseid' => $courseid,
]);
@ -906,6 +908,9 @@ class core_calendar_external extends external_api {
$context = \context_user::instance($USER->id);
self::validate_context($context);
$type = \core_calendar\type_factory::get_calendar_instance();
$time = $type->convert_to_timestamp($year, $month, 1);
$calendar = new calendar_information(0, 0, 0, $time);
$calendar->prepare_for_view($course, $courses);
@ -922,7 +927,8 @@ class core_calendar_external extends external_api {
public static function get_calendar_monthly_view_parameters() {
return new external_function_parameters(
[
'time' => new external_value(PARAM_INT, 'Time to be viewed', VALUE_REQUIRED, '', NULL_NOT_ALLOWED),
'year' => new external_value(PARAM_INT, 'Month to be viewed', VALUE_REQUIRED),
'month' => new external_value(PARAM_INT, 'Year to be viewed', VALUE_REQUIRED),
'courseid' => new external_value(PARAM_INT, 'Course being viewed', VALUE_DEFAULT, SITEID, NULL_ALLOWED),
]
);

View File

@ -32,14 +32,13 @@
}
}}
<div{{!
}} id="calendar-month-{{uniqid}}-{{time}}" {{!
}} id="calendar-month-{{date.year}}-{{date.month}}-{{uniqid}}" {{!
}} data-template="core_calendar/month_mini" {{!
}} data-includenavigation="{{#includenavigation}}true{{/includenavigation}}{{^includenavigation}}false{{/includenavigation}}"{{!
}}>
{{> core_calendar/month_mini}}
</div>
{{#js}}
require(['jquery', 'core_calendar/calendar_mini'], function($, CalendarMini) {
CalendarMini.init($("#calendar-month-{{uniqid}}-{{time}}"));
CalendarMini.init($("#calendar-month-{{date.year}}-{{date.month}}-{{uniqid}}"));
});
{{/js}}

View File

@ -31,7 +31,7 @@
{
}
}}
<div class="calendarwrapper" data-courseid="{{courseid}}" data-current-time="{{time}}">
<div class="calendarwrapper" data-courseid="{{courseid}}" data-month="{{date.mon}}" data-year="{{date.year}}">
{{> core_calendar/month_header }}
{{> core_calendar/month_navigation }}
{{> core/overlay_loading}}

View File

@ -31,17 +31,39 @@
{
}
}}
<div id="month-mini-{{uniqid}}-{{time}}" class="calendarwrapper" data-courseid="{{courseid}}" data-current-time="{{time}}">
<div{{!
}} id="month-mini-{{date.year}}-{{date.month}}-{{uniqid}}"{{!
}} class="calendarwrapper"{{!
}} data-courseid="{{courseid}}"{{!
}} data-month="{{date.mon}}"{{!
}} data-year="{{date.year}}"{{!
}}>
{{> core/overlay_loading}}
<table class="minicalendar calendartable">
<caption class="calendar-controls">
<a href="#" class="arrow_link previous" title="{{#str}}monthprev, calendar{{/str}}" data-time="{{previousperiod}}"><span class="arrow">{{{larrow}}}</span></a>
<a{{!
}} href="#"{{!
}} class="arrow_link previous"{{!
}} title="{{#str}}monthprev, calendar{{/str}}"{{!
}} data-year="{{previousperiod.year}}"{{!
}} data-month="{{previousperiod.mon}}"{{!
}}>
<span class="arrow">{{{larrow}}}</span>
</a>
<span class="hide"> | </span>
<span class="current">
<a href="{{{url}}}" title="{{#str}}monththis, calendar{{/str}}" data-time="">{{periodname}}</a>
<a href="{{{url}}}" title="{{#str}}monththis, calendar{{/str}}">{{periodname}}</a>
</span>
<span class="hide"> | </span>
<a href="#" class="arrow_link next" title="{{#str}}monthnext, calendar{{/str}}" data-time="{{nextperiod}}"><span class="arrow">{{{rarrow}}}</span></a>
<a{{!
}} href="#"{{!
}} class="arrow_link next"{{!
}} title="{{#str}}monthprev, calendar{{/str}}"{{!
}} data-year="{{nextperiod.year}}"{{!
}} data-month="{{nextperiod.mon}}"{{!
}}>
<span class="arrow">{{{rarrow}}}</span>
</a>
</caption>
<thead>
<tr>
@ -145,7 +167,7 @@ require([
M.util.js_pending("month-mini-{{uniqid}}-filterChanged");
// A filter value has been changed.
// Find all matching cells in the popover data, and hide them.
$("#month-mini-{{uniqid}}-{{time}}")
$("#month-mini-{{date.year}}-{{date.month}}-{{uniqid}}")
.find(CalendarSelectors.popoverType[data.type])
.toggleClass('hidden', !!data.hidden);
M.util.js_complete("month-mini-{{uniqid}}-filterChanged");

View File

@ -31,11 +31,37 @@
{
}
}}
{{#navigation}}
<div id="month-navigation-{{uniqid}}" class="controls" data-view="{{view}}">
{{{navigation}}}
<div class="calendar-controls">
<a{{!
}} href="{{previousperiodlink}}"{{!
}} class="arrow_link previous"{{!
}} title="{{#str}}monthprev, calendar{{/str}}"{{!
}} data-year="{{previousperiod.year}}"{{!
}} data-month="{{previousperiod.mon}}"{{!
}} data-drop-zone="nav-link" {{!
}}>
<span class="arrow">{{{larrow}}}</span>
&nbsp;
<span class="arrow_text">{{previousperiodname}}</span>
</a>
<span class="hide"> | </span>
<h2 class="current">{{periodname}}</h2>
<span class="hide"> | </span>
<a{{!
}} href="{{nextperiodlink}}"{{!
}} class="arrow_link next"{{!
}} title="{{#str}}monthnext, calendar{{/str}}"{{!
}} data-year="{{nextperiod.year}}"{{!
}} data-month="{{nextperiod.mon}}"{{!
}} data-drop-zone="nav-link" {{!
}}>
<span class="arrow_text">{{nextperiodname}}</span>
&nbsp;
<span class="arrow">{{{rarrow}}}</span>
</a>
</div>
</div>
{{/navigation}}
{{#js}}
require(['jquery', 'core_calendar/month_navigation_drag_drop'], function($, DragDrop) {
var root = $('#month-navigation-{{uniqid}}');

View File

@ -51,22 +51,10 @@ require_once($CFG->dirroot.'/calendar/lib.php');
$courseid = optional_param('course', SITEID, PARAM_INT);
$view = optional_param('view', 'upcoming', PARAM_ALPHA);
$day = optional_param('cal_d', 0, PARAM_INT);
$mon = optional_param('cal_m', 0, PARAM_INT);
$year = optional_param('cal_y', 0, PARAM_INT);
$time = optional_param('time', 0, PARAM_INT);
$url = new moodle_url('/calendar/view.php');
// If a day, month and year were passed then convert it to a timestamp. If these were passed
// then we can assume the day, month and year are passed as Gregorian, as no where in core
// should we be passing these values rather than the time. This is done for BC.
if (!empty($day) && !empty($mon) && !empty($year)) {
if (checkdate($mon, $day, $year)) {
$time = make_timestamp($year, $mon, $day);
}
}
if (empty($time)) {
$time = time();
}