Event times do not honor timezone offset when subscribed in iCal

26 views
Skip to first unread message

jlg

unread,
May 3, 2011, 4:40:23 PM5/3/11
to planscalendar
Running Plans 8.2.1, I have a calendar with a timezone offset of -6. I
create an event at 6:30 AM on a given day. When I subscribe to the
calendar using iCal, the event shows up at 6:30 AM GMT instead of
GMT-6. This causes all events on the calendar to be 6 hours off when
viewed in iCal.

Is there a way to fix this?

jlg

unread,
May 3, 2011, 5:17:18 PM5/3/11
to planscalendar
Well, the easiest way to fix it was to set the calendar to auto-update
on a daily basis. Apparently, if the calendar is stored on MobileMe
instead of the local computer, the manual update doesn't work. So,
it's an iCal bug instead of a Plans bug.

Now, to figure out how to make Plans automatically account for DST...

jlg

unread,
May 3, 2011, 6:06:55 PM5/3/11
to planscalendar
Here's how to sort of fix the DST issue, at least in iCal exports.

Edit plans_lib.pl, find the event2ical subroutine, and make the first
part of it look like this:

sub event2ical() {
my ($event_ref) = @_;
my %event = %{$event_ref};
my $results;

my $start_timestamp = $event{start} - $calendars{$event{cal_ids}[0]}
{gmtime_diff}*3600;
my $end_timestamp = $event{end} - $calendars{$event{cal_ids}[0]}
{gmtime_diff}*3600;

my @timestamp_array = localtime($event{start});
my $ndst = $timestamp_array[8];
my $dst_start_timestamp = $event{start} - ( $ndst * 3600 );
my $dst_end_timestamp = $event{end} - ( $ndst * 3600 );

my $cal_title = $calendars{$event{cal_ids}[0]}{title}; # need to
add titles for all other cal_ids

my $dtstart_string = "";
my $dtend_string = "";

my $rightnow_date = &outlook_date_time($rightnow) . 'Z';

if ($event{all_day_event} eq "1") {
$dtstart_string = ";VALUE=DATE:".&outlook_date($event{start});
$dtend_string = ";VALUE=DATE:".&outlook_date($event{end}+86400);
} else {
# $dtstart_string = ":".&outlook_date_time($event{start}) . 'Z';
# $dtend_string = ":".&outlook_date_time($event{end}) . 'Z';
$dtstart_string = ":".&outlook_date_time($dst_start_timestamp) .
'Z';
$dtend_string = ":".&outlook_date_time($dst_end_timestamp) . 'Z';
}

jlg

unread,
May 3, 2011, 6:11:15 PM5/3/11
to planscalendar
This fix assumes that you set the timezone offset for your calendars
to the correct non-DST offset, and that your calendars use your
server's local timezone.

As the script generates iCal events, it checks to see if the beginning
of the event falls within DST; if so, it subtracts an additional hour
from the start and end times. Events that fall on the DST changeovers
might not translate correctly, but in general it should work.
Reply all
Reply to author
Forward
0 new messages