diff -Nuriw a/calendar/lib.php b/calendar/lib.php
--- a/calendar/lib.php 2014-10-24 14:13:46.000000000 +0100
+++ b/calendar/lib.php 2014-10-24 14:14:33.000000000 +0100
@@ -249,7 +249,7 @@
// These are used for DB queries, so we want unixtime, so we need to use Gregorian dates.
$display->tstart = make_timestamp($gy, $gm, $gd, $gh, $gmin, 0);
- $display->tend = $display->tstart + ($display->maxdays * DAYSECS) - 1;
+ $display->tend = $display->tstart + strtotime("+$display->maxdays day",0) - 1;
// Align the starting weekday to fall in our display range
// This is simple, not foolproof.
@@ -318,9 +318,10 @@
}
// Now display all the calendar
- $daytime = $display->tstart - DAYSECS;
+
+ $daytime = strtotime( '-1 day',$display->tstart);
for($day = 1; $day <= $display->maxdays; ++$day, ++$dayweek) {
- $daytime += DAYSECS;
+ $daytime = strtotime('+1 day', $daytime);
if($dayweek > $display->maxwday) {
// We need to change week (table row)
$content .= '
';
@@ -534,7 +535,7 @@
// This works correctly with respect to the user's DST, but it is accurate
// only because $fromtime is always the exact midnight of some day!
- $display->tend = usergetmidnight($display->tstart + DAYSECS * $display->range + 3 * HOURSECS) - 1;
+ $display->tend = usergetmidnight( strtotime('+1 day',$display->tstart) * $display->range + 3 * HOURSECS) - 1;
// Get the events matching our criteria
$events = calendar_get_events($display->tstart, $display->tend, $users, $groups, $courses);
@@ -957,8 +958,8 @@
case 'day':
$days = calendar_get_days();
- $prevtimestamp = $time - DAYSECS;
- $nexttimestamp = $time + DAYSECS;
+ $prevtimestamp = strtotime('-1 day',$time);
+ $nexttimestamp = strtotime('+1 day',$time);
$prevdate = $calendartype->timestamp_to_date_array($prevtimestamp);
$nextdate = $calendartype->timestamp_to_date_array($nexttimestamp);
@@ -1675,7 +1676,7 @@
// Check if we will still be on the same day.
if ($usermidnightstart == $usermidnightend) {
// Check if we are running all day.
- if ($event->timeduration == DAYSECS) {
+ if ($event->timeduration == strtotime('1 day',0)) {
$time = get_string('allday', 'calendar');
} else { // Specify the time we will be running this from.
$datestart = calendar_time_representation($starttime);
@@ -1704,7 +1705,7 @@
$timeend = calendar_time_representation($event->timestart + $event->timeduration);
// Set printable representation.
- if ($now >= $usermidnightstart && $now < ($usermidnightstart + DAYSECS)) {
+ if ($now >= $usermidnightstart && $now < (strtotime('+1 day', $usermidnightstart))) {
$url = calendar_get_link_href(new moodle_url(CALENDAR_URL . 'view.php', $linkparams), 0, 0, 0, $endtime);
$eventtime = $timestart . ' » ' . html_writer::link($url, $dayend) . $timeend;
} else {
@@ -2751,7 +2752,7 @@
* @return int tomorrow timestamp
*/
public function timestamp_tomorrow() {
- return $this->time + DAYSECS;
+ return strtotime('+1 day',$this->time);
}
/**
* Adds the pretend blocks for the calendar
diff -Nuriw a/calendar/renderer.php b/calendar/renderer.php
--- a/calendar/renderer.php 2014-10-24 13:16:41.000000000 +0100
+++ b/calendar/renderer.php 2014-10-24 13:20:23.000000000 +0100
@@ -89,10 +89,9 @@
if ($CFG->calendar_customexport) {
$a = new stdClass();
$now = time();
- $time = $now - $CFG->calendar_exportlookback * DAYSECS;
-
+ $time = $now - strtotime("+ $CFG->calendar_exportlookback day",0);
$a->timestart = userdate($time, get_string('strftimedatefullshort', 'langconfig'));
- $time = $now + $CFG->calendar_exportlookahead * DAYSECS;
+ $time = $now + strtotime("+$CFG->calendar_exportlookahead day",0);
$a->timeend = userdate($time, get_string('strftimedatefullshort', 'langconfig'));
$output .= html_writer::empty_tag('input', array('type' => 'radio', 'name' => 'preset_time', 'id' => 'pt_custom', 'value' => 'custom'));
$output .= html_writer::tag('label', get_string('customexport', 'calendar', $a), array('for' => 'pt_custom'));
@@ -439,7 +438,7 @@
// These are used for DB queries, so we want unixtime, so we need to use Gregorian dates.
$display->tstart = make_timestamp($gy, $gm, $gd, $gh, $gmin, 0);
- $display->tend = $display->tstart + ($display->maxdays * DAYSECS) - 1;
+ $display->tend = $display->tstart + strtotime("+$display->maxdays day",0) - 1;
// Align the starting weekday to fall in our display range
// This is simple, not foolproof.
@@ -504,9 +503,9 @@
$weekend = intval($CFG->calendar_weekend);
}
- $daytime = $display->tstart - DAYSECS;
+ $daytime = strtotime( '-1 day',$display->tstart);
for ($day = 1; $day <= $display->maxdays; ++$day, ++$dayweek) {
- $daytime = $daytime + DAYSECS;
+ $daytime = strtotime('+1 day', $daytime);
if($dayweek > $display->maxwday) {
// We need to change week (table row)
$table->data[] = $row;