From 7d565474b41400bfce2d665da96d39631458eda3 Mon Sep 17 00:00:00 2001 From: Jim Hu Date: Fri, 26 Dec 2008 05:54:46 +0000 Subject: fix US holidays; fix 1743686 where byday set and timezone pushes event to different day --- functions/parse/end_vevent.php | 6 ++++++ functions/parse/parse_tzs.php | 25 +++++++++++++--------- functions/parse/recur_functions.php | 42 +++++++++++++++---------------------- 3 files changed, 38 insertions(+), 35 deletions(-) (limited to 'functions/parse') diff --git a/functions/parse/end_vevent.php b/functions/parse/end_vevent.php index 5970e65..80e1ce9 100644 --- a/functions/parse/end_vevent.php +++ b/functions/parse/end_vevent.php @@ -292,12 +292,18 @@ sort($recur_data); // This used to use 5 different blocks to write the array... can it be reduced further? $recur_data_hour = @substr($start_time,0,2); $recur_data_minute = @substr($start_time,2,2); +if (isset($allday_start) && $allday_start != ''){ + $recur_data_hour = '00'; + $recur_data_minute = '00'; +} foreach($recur_data as $recur_data_unixtime) { $recur_data_year = date('Y', $recur_data_unixtime); $recur_data_month = date('m', $recur_data_unixtime); $recur_data_day = date('d', $recur_data_unixtime); $recur_data_date = $recur_data_year.$recur_data_month.$recur_data_day; + /* at this point the recur data year, month, day, hour, and minute are in the default timezone for the phpicalendar installation, if that is set. We need to compare whether both the event timezone and the the phpicaledar timezone are in the same state wrt std vs daylight time. */ + if (isset($allday_start) && $allday_start != '') { $start_time2 = $recur_data_unixtime; $end_time2 = strtotime('+'.$diff_allday_days.' days', $recur_data_unixtime); diff --git a/functions/parse/parse_tzs.php b/functions/parse/parse_tzs.php index c431d29..734851e 100644 --- a/functions/parse/parse_tzs.php +++ b/functions/parse/parse_tzs.php @@ -6,6 +6,9 @@ if (trim($nextline) != 'BEGIN:VCALENDAR') exit(error($lang['l_error_invalidcal'] // read file in line by line // XXX end line is skipped because of the 1-line readahead +$is_daylight = false; +$is_std = false; + while (!feof($ifile)) { $line = $nextline; $nextline = fgets($ifile, 1024); @@ -16,10 +19,7 @@ while (!feof($ifile)) { $nextline = fgets($ifile, 1024); $nextline = ereg_replace("[\r\n]", "", $nextline); } - $line = trim($line); - $is_daylight = false; - $is_std = false; - + $line = trim($line); switch ($line) { case 'BEGIN:VTIMEZONE': unset($tz_name, $offset_from, $offset_to, $tz_id); @@ -55,13 +55,12 @@ while (!feof($ifile)) { break; default: unset ( $data, $prop_pos, $property); - if (ereg ("([^:]+):(.*)", $line, $line)){ - $property = $line[1]; - $data = $line[2]; + if (ereg ("([^:]+):(.*)", $line, $arr)){ + $property = $arr[1]; + $data = $arr[2]; $prop_pos = strpos($property,';'); if ($prop_pos !== false) $property = substr($property,0,$prop_pos); $property = strtoupper($property); - switch ($property) { case 'TZID': $tz_id = $data; @@ -73,8 +72,14 @@ while (!feof($ifile)) { $offset_to = $data; break; case 'DTSTART': - if($is_std) $begin_std = $data; - if($is_daylight) $begin_daylight = $data; + if($is_std || $is_daylight){ + $datetime = extractDateTime($data, $property, $field); + $start_unixtime = $datetime[0]; + $start_date = $datetime[1]; + $year = substr($start_date,0,4); + if($is_std) $begin_std[$year] = $data; + if($is_daylight) $begin_daylight[$year] = $data; + } break; case 'TZNAME': if($is_std) $st_name = $data; diff --git a/functions/parse/recur_functions.php b/functions/parse/recur_functions.php index 6a58d2d..2328e4b 100644 --- a/functions/parse/recur_functions.php +++ b/functions/parse/recur_functions.php @@ -1,33 +1,18 @@ = $start_date_unixtime && $date <= $until_date){ + # day offset fixes shifts across day boundaries due to time diffs. + # These are already fixed for the initial instance, but need to be fixed for recurrences + if (date("Ymd", $time) != $start_date) $time = $time + $day_offset * (24*60*60); + if(isset($time) + && !in_array($time, $recur_data) + && !in_array($date, $except_dates) + && $time >= $start_date_unixtime + && $date <= $until_date + ){ $count--; #echo "\n.$count\n"; - if($time >= $mArray_begin && - $time <= $mArray_end - && $count >= 0 + if($time >= $mArray_begin + && $time <= $mArray_end + && $count >= 0 ) $recur_data[] = $time; } } -- cgit v1.2.3