Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can this parser handle Daylight Saving? #201

Closed
te-online opened this issue Jan 30, 2019 · 4 comments
Closed

Can this parser handle Daylight Saving? #201

te-online opened this issue Jan 30, 2019 · 4 comments
Labels

Comments

@te-online
Copy link

te-online commented Jan 30, 2019

  • PHP Version: 7.0.x
  • PHP date.timezone: Europe/Berlin
  • ICS Parser Version: 2.1.8
  • Linux

Description of the Issue:

This issue is very hard for me understand, because I can barely understand the offending iCal feed. But it seems to me, that the parser does not factor in daylight saving time.

My goal is to convert all events from an ICS feed to UTC timestamps to save in a database.

I use the following code

  $start = $ical->iCalDateToDateTime($event->dtstart_array[3], true);
  $start->setTimezone(new DateTimeZone('UTC'));
  var_dump($start->format('U')); // This should be saved

Steps to Reproduce:

It works fine with most feeds, but not when I use this calendar. Events are 1 hour off in the database.

BEGIN:VCALENDAR
VERSION:2.0
CALSCALE:GREGORIAN
PRODID:-//SabreDAV//SabreDAV//EN
X-WR-CALNAME:Personal (test)
BEGIN:VTIMEZONE
TZID:W. Europe Standard Time
BEGIN:STANDARD
DTSTART:19701025T030000
RRULE:FREQ=YEARLY;BYDAY=-1SU;BYHOUR=3;BYMINUTE=0;BYMONTH=10
TZNAME:W. Europe Standard Time
TZOFFSETFROM:+0200
TZOFFSETTO:+0100
END:STANDARD
BEGIN:DAYLIGHT
DTSTART:19700329T020000
RRULE:FREQ=YEARLY;BYDAY=-1SU;BYHOUR=2;BYMINUTE=0;BYMONTH=3
TZNAME:W. Europe Daylight Time
TZOFFSETFROM:+0100
TZOFFSETTO:+0200
END:DAYLIGHT
END:VTIMEZONE
BEGIN:VEVENT
CLASS:PUBLIC
DTEND;TZID=W. Europe Standard Time:20190130T100000
DTSTAMP:20190129T224855Z
DTSTART;TZID=W. Europe Standard Time:20190130T090000
PRIORITY:5
SEQUENCE:1
SUMMARY:test
TRANSP:OPAQUE
UID:OEBVXS96OXD8ID7GZUW8
X-MICROSOFT-CDO-BUSYSTATUS:BUSY
END:VEVENT
BEGIN:VEVENT
CLASS:PUBLIC
DESCRIPTION: 
DTEND;TZID=W. Europe Standard Time:20190116T083000
DTSTAMP:20190129T224854Z
DTSTART;TZID=W. Europe Standard Time:20190116T080000
PRIORITY:5
SEQUENCE:0
SUMMARY:Testevent
TRANSP:OPAQUE
UID:e486ca98-c860-4468-8da8-ada16784a638
X-MICROSOFT-CDO-BUSYSTATUS:BUSY
END:VEVENT
END:VCALENDAR

I would assume that these events needed to be -1 (or -2?) hour in UTC, but they come out as they are in the file.

Is there something wrong with my code or is it simply a feature not implemented in the parser? Or an issue with the calendar feed?

@u01jmg3 u01jmg3 self-assigned this Jan 30, 2019
@u01jmg3
Copy link
Owner

u01jmg3 commented Mar 6, 2019

@te-online
Copy link
Author

te-online commented Mar 7, 2019

Thanks for following up :-)

I believe, the timezone in this calendar is “W. Europe Standard Time”, which is apparently Microsofts way of saying “Europe/Berlin” or similar. See https://support.microsoft.com/en-nz/help/973627/microsoft-time-zone-index-values, search for “W. Europe Standard Time”. (These events are created by Outlook...).

When it's daylight saving time, it switches to “W. Europe Daylight Time” instead.

I'd still say, it'd be expected to “remove” the offset when converting to UTC? What is your opinion?

Maybe it's this part that is not entirely respected?

BEGIN:VTIMEZONE
TZID:W. Europe Standard Time
BEGIN:STANDARD
DTSTART:19701025T030000
RRULE:FREQ=YEARLY;BYDAY=-1SU;BYHOUR=3;BYMINUTE=0;BYMONTH=10
TZNAME:W. Europe Standard Time
TZOFFSETFROM:+0200
TZOFFSETTO:+0100
END:STANDARD
BEGIN:DAYLIGHT
DTSTART:19700329T020000
RRULE:FREQ=YEARLY;BYDAY=-1SU;BYHOUR=2;BYMINUTE=0;BYMONTH=3
TZNAME:W. Europe Daylight Time
TZOFFSETFROM:+0100
TZOFFSETTO:+0200
END:DAYLIGHT
END:VTIMEZONE

@u01jmg3
Copy link
Owner

u01jmg3 commented Mar 8, 2019

Have you tried using $replaceWindowsTimeZoneIds (brought in by PR #187)?

This will correct the timezone to "Europe/Berlin".

@marcelstoer
Copy link
Contributor

Can this parser handle Daylight Saving?

Yes, it can. For Windows calendars you need the flag described above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants