From: defacer Date: Wed, 1 Dec 2004 21:54:49 +0000 (+0000) Subject: Removed last instance of the evil SECS_IN_DAY constant that is the ticket X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=9c6bf80e719845b1d3b2094c347f3bb6e8dc982b;p=moodle.git Removed last instance of the evil SECS_IN_DAY constant that is the ticket to wrong code when DST comes into play Fixed calendar_get_upcoming to perform DST corrections according to the server's TZ (now the users as calendar doesn't support that, but it's a start) Removed some dead code --- diff --git a/calendar/lib.php b/calendar/lib.php index e563c1a151..3813f67517 100644 --- a/calendar/lib.php +++ b/calendar/lib.php @@ -46,7 +46,6 @@ else { define ('CALENDAR_STARTING_WEEKDAY', intval($firstday) % 7); } -define ('SECS_IN_DAY', 86400); define ('CALENDAR_UPCOMING_DAYS', 21); define ('CALENDAR_UPCOMING_MAXEVENTS', 10); define ('CALENDAR_URL', $CFG->wwwroot.'/calendar/'); @@ -287,13 +286,8 @@ function calendar_get_upcoming($courses, $groups, $users, $daysinfuture, $maxeve $display->tstart = $usermidnighttoday; } - // 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; + // This does include DST compensation, but unfortunately only with respect to the server's TZ + $display->tend = strtotime('+'.$display->range.' days', $display->tstart) - 1; // Get the events matching our criteria $whereclause = calendar_sql_where($display->tstart, $display->tend, $users, $groups, $courses); @@ -922,13 +916,8 @@ function calendar_session_vars() { } function calendar_overlib_html() { - global $CFG; - - $html = ''; - $html .= ''; - $html .= ''; - - return $html; + return '' + .''; } function calendar_set_referring_course($courseid) { @@ -1166,15 +1155,4 @@ function calendar_format_event_time($event, $now, $morehref, $usecommonwords = t return $eventtime; } -if(!function_exists('array_diff_assoc')) { - // PHP < 4.3.0 - function array_diff_assoc($source, $diff) { - $res = $source; - foreach ($diff as $key=>$data) { - unset($res[$key]); - } - return $res; - } -} - ?>