Enough-Software / enough_icalendar

iCalendar library to parse, generate and respond to iCal / ics invites. Fully compliant with RFC 5545 (iCalendar) and RFC 5546 (iTIP).
Mozilla Public License 2.0
10 stars 9 forks source link

UTC time not correctly parsed #14

Open vanlooverenkoen opened 9 months ago

vanlooverenkoen commented 9 months ago

The F1 ics returns utc date times:

DTSTART:20240302T150000Z
DTEND:20240302T170000Z
SUMMARY:🏁 FORMULA 1 GULF AIR BAHRAIN GRAND PRIX 2024 - Race

URL: webcal://ics.ecal.com/ecal-sub/65d5e5b6532bea0008b2ee55/Formula%201.ics

But they are not parsed correctly. They are parsed as local time. I live in belgium so I get:

20240302T150000
20240302T170000

If I convert this to utc it becomes:

20240302T150000Z
20240302T160000Z

The output for my local time should be:

20240302T160000
20240302T180000
robert-virkus commented 9 months ago

Hey, thanks for your report! I believe this still works as expected after verifying this with the following test case:

test(
        'UTC time parsing test',
        () {
          const text = '''BEGIN:VCALENDAR
VERSION:3.0
BEGIN:VEVENT
UID:19970610T172345Z-AF23B2@example.com
DTSTAMP:20240302T150000Z
DTSTART:20240302T150000Z
DTEND:20240302T170000Z
SUMMARY:🏁 FORMULA 1 GULF AIR BAHRAIN GRAND PRIX 2024 - Race
END:VEVENT
END:VCALENDAR''';
          final calendar = VComponent.parse(text);
          expect(calendar, isA<VCalendar>());
          expect(calendar.children, isNotEmpty);
          expect(calendar.children.length, 1);
          expect(calendar.version, '3.0');
          final event = calendar.children.first;
          expect(event, isA<VEvent>());
          expect(
            (event as VEvent).summary,
            '🏁 FORMULA 1 GULF AIR BAHRAIN GRAND PRIX 2024 - Race',
          );
          expect(event.start, DateTime.utc(2024, 03, 02, 15, 00, 00));
          expect(event.end, DateTime.utc(2024, 03, 02, 17, 00, 00));
        },
      );

All date times given by the API are returned in UTC. Can you show me your code how you handle the dates?