From 3c7e1b65be8e4d954f0b4569871c9dd2ef2e6f72 Mon Sep 17 00:00:00 2001 From: defacer Date: Sat, 20 Nov 2004 20:10:03 +0000 Subject: [PATCH] Fixes for slightly incorrect behavior on days where the DST setting changes. Not quite correct in some places though (those require more attention). --- calendar/lib.php | 7 +++++-- calendar/view.php | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/calendar/lib.php b/calendar/lib.php index 87bfb8ef1f..0c1fc168fc 100644 --- a/calendar/lib.php +++ b/calendar/lib.php @@ -290,6 +290,9 @@ function calendar_get_upcoming($courses, $groups, $users, $daysinfuture, $maxeve // This effectively adds as many days as needed, and the final SECS_IN_DAY - 1 // serves to cover the duration until the end of the final day. We could // just do another gmmktime() and an addition, but this is "faster" :) + + // WARNING: IT IS ALSO BUGGY WITH REGARDS TO DST CHANGES! THIS HAS TO BE FIXED SOMEDAY! + // IF YOU DO SECS ARITHMETIC, THE CODE WILL ALWAYS BE BUGGY WITH REGARD TO DST! $display->tend = $display->tstart + (SECS_IN_DAY * $display->range) - 1; // Get the events matching our criteria @@ -535,8 +538,8 @@ function calendar_top_controls($type, $data) { case 'day': $data['d'] = $date['mday']; // Just for convenience $dayname = calendar_wday_name($date['weekday']); - $prevdate = getdate($time - SECS_IN_DAY); - $nextdate = getdate($time + SECS_IN_DAY); + $prevdate = getdate(make_timestamp($data['y'], $data['m'], $data['d'] - 1)); + $nextdate = getdate(make_timestamp($data['y'], $data['m'], $data['d'] + 1)); $prevname = calendar_wday_name($prevdate['weekday']); $nextname = calendar_wday_name($nextdate['weekday']); $content .= "\n"; diff --git a/calendar/view.php b/calendar/view.php index a12992e7f6..1fb3d57f81 100644 --- a/calendar/view.php +++ b/calendar/view.php @@ -193,7 +193,7 @@ function calendar_show_day($d, $m, $y, $courses, $groups, $users) { $getvars = 'from=day&cal_d='.$d.'&cal_m='.$m.'&cal_y='.$y; // For filtering $starttime = make_timestamp($y, $m, $d); - $endtime = $starttime + SECS_IN_DAY - 1; + $endtime = make_timestamp($y, $m, $d + 1) - 1; $events = calendar_get_upcoming($courses, $groups, $users, 1, 100, $starttime); -- 2.39.5