diff -Naur WebCalendar-1.2.0.orig/includes/functions.php WebCalendar-1.2.0.new/includes/functions.php --- WebCalendar-1.2.0.orig/includes/functions.php 2009-10-12 15:32:31.000000000 +0200 +++ WebCalendar-1.2.0.new/includes/functions.php 2009-10-12 15:50:35.000000000 +0200 @@ -139,6 +139,29 @@ return sprintf ( "%d%02d00", $minutes / 60, $minutes % 60 ); } +/* Bump UNIX local timestamp with the given duration. + * param int $ts input timestamp + * param int $hour hour duration + * param int $minute minute duration + * param int $second second duration + * param int $month month duration + * param int $day day duration + * param int $year year duration + * + * This function overcomes problems due to daylight saving change dates; + * it is based on the fact that function mktime() accepts out of range + * data. + */ + +function bump_local_timestamp($ts, $hour = 0, $minute = 0, $second = 0, + $month = 0, $day = 0, $year = 0) + +{ + return mktime(date('G', $ts) + $hour, date('i', $ts) + $minute, + date('s', $ts) + $second, date('n', $ts) + $month, + date('j', $ts) + $day, date('Y', $ts) + $year); +} + /* Builds the HTML for the event label. * * @param string $can_access diff -Naur WebCalendar-1.2.0.orig/includes/init.php WebCalendar-1.2.0.new/includes/init.php --- WebCalendar-1.2.0.orig/includes/init.php 2009-10-12 15:32:31.000000000 +0200 +++ WebCalendar-1.2.0.new/includes/init.php 2009-10-12 15:55:43.000000000 +0200 @@ -411,8 +411,8 @@ $wkstart = get_weekday_before ( $y, $m, $d ); $lastDay = ( $DISPLAY_WEEKENDS == 'N' ? 4 : 6 ); for ( $i = -5; $i <= 9; $i++ ) { - $twkstart = $wkstart + ( 604800 * $i ); - $twkend = $twkstart + ( 86400 * $lastDay ); + $twkstart = bump_local_timestamp($wkstart, 0, 0, 0, 0, 7 * $i, 0); + $twkend = bump_local_timestamp($twkstart, 0, 0, 0, 0, $lastDay, 0); $dateSYmd = date ( 'Ymd', $twkstart ); $dateEYmd = date ( 'Ymd', $twkend ); $dateW = date ( 'W', $twkstart + 86400 ); diff -Naur WebCalendar-1.2.0.orig/view_v.php WebCalendar-1.2.0.new/view_v.php --- WebCalendar-1.2.0.orig/view_v.php 2008-03-07 21:15:45.000000000 +0100 +++ WebCalendar-1.2.0.new/view_v.php 2009-10-12 16:04:55.000000000 +0200 @@ -34,10 +34,10 @@ $nextdate = date ( 'Ymd', mktime ( 0, 0, 0, $thismonth, $thisday + 7, $thisyear ) ); $prevdate = date ( 'Ymd', mktime ( 0, 0, 0, $thismonth, $thisday - 7, $thisyear ) ); -$wkstart = get_weekday_before ( $thisyear, $thismonth, $thisday + 1 ); - -$wkend = $wkstart + ( 86400 * ( $DISPLAY_WEEKENDS == 'N' ? 5 : 7 ) ); -$thisdate = date ( 'Ymd', $wkstart ); +$wkstart = get_weekday_before($thisyear, $thismonth, $thisday + 1); +$wkend = bump_local_timestamp($wkstart, 0, 0, 0, 0, + $DISPLAY_WEEKENDS == 'N'? 5: 7, 0) - 1; +$thisdate = date('Ymd', $wkstart); $nextStr = translate ( 'Next' ); $prevStr = translate ( 'Previous' ); @@ -108,7 +108,8 @@ $body .= ' <tr> <th class="row" style="width:' . $tdw . '%;">' . $tempfullname . '</th>'; - for ( $date = $wkstart; $date < $wkend; $date += 86400 ) { + for ($date = $wkstart; $date <= $wkend; + $date = bump_local_timestamp($date, 0, 0, 0, 0, 1, 0)) { $is_weekend = is_weekend ( $date ); if ( $is_weekend && $DISPLAY_WEEKENDS == 'N' ) continue;