Commit 60c78022 authored by Robert Rollins's avatar Robert Rollins

Final fix for the non-UTC UNTIL feature (I hope).

parent 17349daa
...@@ -52,17 +52,21 @@ function _date_ical_get_repeat_dates($field_name, $repeat_data, $item, $source) ...@@ -52,17 +52,21 @@ function _date_ical_get_repeat_dates($field_name, $repeat_data, $item, $source)
$rrule_values['UNTIL']['tz'] = $timezone; $rrule_values['UNTIL']['tz'] = $timezone;
// Convert the unparsed UNTIL to UTC, since the Date code will use it. // Convert the unparsed UNTIL to UTC, since the Date code will use it.
// It's currently got a Z on it, but only because iCalcreator blindly // It may currently have a Z on it, but only because iCalcreator blindly
// added it. Since the user set "until_not_utc", we know it's not UTC. // adds one to DATETIME-type UNTILs if it's not there.
$matches = array(); $matches = array();
if (preg_match('/^(.*?)UNTIL=(.*?)Z(.*?)$/', $repeat_data['RRULE'], $matches)) { if (preg_match('/^(.*?)UNTIL=(.*?)Z?(.*?)$/', $repeat_data['RRULE'], $matches)) {
$until_date = new DateObject($matches[2], $timezone); // If the UNTIL value doesn't have a "T", it's a DATE, making timezone
$until_date->setTimezone(new DateTimeZone('UTC')); // fixes irrelvant.
$matches[2] = $until_date->format('Ymd\THis'); if (strpos($matches[2], 'T') !== FALSE) {
$repeat_data['RRULE'] = "{$matches[1]}UNTIL={$matches[2]}Z{$matches[3]}"; $until_date = new DateObject($matches[2], $timezone);
$until_date->setTimezone(new DateTimeZone('UTC'));
$matches[2] = $until_date->format('Ymd\THis');
$repeat_data['RRULE'] = "{$matches[1]}UNTIL={$matches[2]}Z{$matches[3]}";
}
} }
else { else {
watchdog('date_ical', 'The RRULE string %rrule could not be parsed to fix the UNTIL value. Date repeats may not be calculated correctly.', watchdog('date_ical', 'The RRULE string "%rrule" could not be parsed to fix the UNTIL value. Date repeats may not be calculated correctly.',
array('%rrule' => $repeat_data['RRULE']), WATCHDOG_WARNING array('%rrule' => $repeat_data['RRULE']), WATCHDOG_WARNING
); );
} }
......
BEGIN:VCALENDAR
PRODID:-//Google Inc//Google Calendar 70.9054//EN
VERSION:2.0
CALSCALE:GREGORIAN
METHOD:PUBLISH
X-WR-CALNAME:Events Feed
X-WR-TIMEZONE:America/New_York
X-WR-CALDESC:A calendar for the events feed
BEGIN:VTIMEZONE
TZID:America/New_York
X-LIC-LOCATION:America/New_York
BEGIN:DAYLIGHT
TZOFFSETFROM:-0500
TZOFFSETTO:-0400
TZNAME:EDT
DTSTART:19700308T020000
RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=2SU
END:DAYLIGHT
BEGIN:STANDARD
TZOFFSETFROM:-0400
TZOFFSETTO:-0500
TZNAME:EST
DTSTART:19701101T020000
RRULE:FREQ=YEARLY;BYMONTH=11;BYDAY=1SU
END:STANDARD
END:VTIMEZONE
BEGIN:VEVENT
SUMMARY:Event w/ Bad UNTIL
UID:12345acbdef1
DTSTART;TZID=America/Los_Angeles:20140323T190000
DTEND;TZID=America/Los_Angeles:20140323T210000
RRULE:FREQ=DAILY;UNTIL=20140328T190000;WKST=SU
DESCRIPTION:description
END:VEVENT
BEGIN:VEVENT
SUMMARY:Event w/ UTC UNTIL
UID:12345acbdef2
DTSTART;TZID=America/Los_Angeles:20140323T190000
DTEND;TZID=America/Los_Angeles:20140323T210000
RRULE:FREQ=DAILY;UNTIL=20140328T230000Z;WKST=SU
DESCRIPTION:description
END:VEVENT
BEGIN:VEVENT
SUMMARY:Event w/ COUNT
UID:12345acbdef3
DTSTART;TZID=America/Los_Angeles:20140323T190000
DTEND;TZID=America/Los_Angeles:20140323T210000
RRULE:FREQ=DAILY;COUNT=6;WKST=SU
DESCRIPTION:description
END:VEVENT
BEGIN:VEVENT
SUMMARY:Event w/ DATE-type UNTIL
UID:12345acbdef4
DTSTART;VALUE=DATE:20140323
DTEND;VALUE=DATE:20140323
RRULE:FREQ=DAILY;UNTIL=20140328;WKST=SU
DESCRIPTION:description
END:VEVENT
END:VALENDAR
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment