u01jmg3 / ics-parser

Parser for iCalendar Events • PHP 8+, 7 (≥ 7.4), 5 (≥ 5.6)
MIT License
448 stars 144 forks source link

Multiple times VTIMEZONE set doesn't work #252

Closed arwinvdv closed 2 years ago

arwinvdv commented 4 years ago

Description of the Issue:

I have a ical from Microsoft and Google with 2 VTIMEZONE's defined. The parser only uses 1 timezone.

Steps to Reproduce:

  1. Use this ical from Microsoft:
    BEGIN:VCALENDAR
    METHOD:PUBLISH
    PRODID:Microsoft Exchange Server 2010
    VERSION:2.0
    X-WR-CALNAME:Example calendar
    BEGIN:VTIMEZONE
    TZID:Customized Time Zone
    BEGIN:STANDARD
    DTSTART:16010101T030000
    TZOFFSETFROM:+0200
    TZOFFSETTO:+0100
    RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=-1SU;BYMONTH=10
    END:STANDARD
    BEGIN:DAYLIGHT
    DTSTART:16010101T020000
    TZOFFSETFROM:+0100
    TZOFFSETTO:+0200
    RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=-1SU;BYMONTH=3
    END:DAYLIGHT
    END:VTIMEZONE
    BEGIN:VTIMEZONE
    TZID:Greenwich Standard Time
    BEGIN:STANDARD
    DTSTART:16010101T000000
    TZOFFSETFROM:+0000
    TZOFFSETTO:+0000
    END:STANDARD
    BEGIN:DAYLIGHT
    DTSTART:16010101T000000
    TZOFFSETFROM:+0000
    TZOFFSETTO:+0000
    END:DAYLIGHT
    END:VTIMEZONE
    BEGIN:VEVENT
    UID:0123
    SUMMARY:example consult 1
    DTSTART;TZID=Customized Time Zone:20191003T093000
    DTEND;TZID=Customized Time Zone:20191003T110000
    CLASS:PUBLIC
    PRIORITY:5
    DTSTAMP:20200103T132704Z
    TRANSP:OPAQUE
    STATUS:CONFIRMED
    SEQUENCE:0
    LOCATION:
    X-MICROSOFT-CDO-APPT-SEQUENCE:0
    X-MICROSOFT-CDO-BUSYSTATUS:BUSY
    X-MICROSOFT-CDO-INTENDEDSTATUS:BUSY
    X-MICROSOFT-CDO-ALLDAYEVENT:FALSE
    X-MICROSOFT-CDO-IMPORTANCE:1
    X-MICROSOFT-CDO-INSTTYPE:0
    X-MICROSOFT-DONOTFORWARDMEETING:FALSE
    X-MICROSOFT-DISALLOW-COUNTER:FALSE
    END:VEVENT
    BEGIN:VEVENT
    UID:12345
    SUMMARY:example consult 2
    DTSTART;TZID=Greenwich Standard Time:20191003T093000
    DTEND;TZID=Greenwich Standard Time:20191003T110000
    CLASS:PUBLIC
    PRIORITY:5
    DTSTAMP:20200103T132704Z
    TRANSP:OPAQUE
    STATUS:CONFIRMED
    SEQUENCE:0
    LOCATION:
    X-MICROSOFT-CDO-APPT-SEQUENCE:0
    X-MICROSOFT-CDO-BUSYSTATUS:BUSY
    X-MICROSOFT-CDO-INTENDEDSTATUS:BUSY
    X-MICROSOFT-CDO-ALLDAYEVENT:FALSE
    X-MICROSOFT-CDO-IMPORTANCE:1
    X-MICROSOFT-CDO-INSTTYPE:0
    X-MICROSOFT-DONOTFORWARDMEETING:FALSE
    X-MICROSOFT-DISALLOW-COUNTER:FALSE
    END:VEVENT
    END:VCALENDAR
  2. The parser doesn't handle the 2 timezones. The 2 events has the same time as output, but they have a different timezone.
u01jmg3 commented 2 years ago

@s0600204: I understand if you're busy but your input would be welcome on this issue

s0600204 commented 2 years ago

The primary issue here can be summed up as a quote from the project's readme:

Requirements

The timezone named Customized Time Zone fails the third requirement.


In order to support user-defined timezones, we'd need a way to specify a timezone in a way that PHP's DateTime class can understand/use it. In other words: we'd need to take what's defined in a VTIMEZONE block and convert it into a DateTimeZone class instance.

Unfortunately, DateTimeZone itself lacks full support for user-defined timezones (with daylight savings transitions et al.) - the best it can do is a single offset-from-UTC.

Thus to support a Standard/Daylight transition we'd need to create two DateTimeZone instances - one for "Standard" and one for "Daylight [Savings]". We'd also need a way to detect which of these two are in effect for any given date-time; apply them consistently with regards to event recurrences; and only do this if the timezone is a user-defined one.

u01jmg3 commented 2 years ago

@arwinvdv: in light of the info @s0600204 has kindly provided, at this point in time, I won't be exploring user-defined timezones unless more users are interested in such a feature. However, if you want to put a PR together, I'd be happy to take a look.