question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Parsing results in wrong time when VTIMEZONE does only contain DAYLIGHT (and no STANDARD)

See original GitHub issue

(Occurs on Android 8 Java and OpenJDK 11)

If this file is parsed:

BEGIN:VCALENDAR
VERSION:2.0
BEGIN:VTIMEZONE
TZID:Europe/Berlin
BEGIN:DAYLIGHT
TZOFFSETFROM:+0100
TZOFFSETTO:+0200
DTSTART:20180325T030000
TZNAME:CEST
END:DAYLIGHT
END:VTIMEZONE
BEGIN:VEVENT
UID:only-dst@example.com 
DTSTAMP:20180329T084939Z
DTSTART;TZID=Europe/Berlin:20180403T090000
DTEND;TZID=Europe/Berlin:20180403T101500
SUMMARY:Sample Event
CREATED:20180329T084939Z
LAST-MODIFIED:20180329T084939Z
END:VEVENT
END:VCALENDAR

with this code:

    javaClass.classLoader.getResourceAsStream("dst-only-vtimezone.ics").use {
        val ical = CalendarBuilder().build(it)
        val vTZ = ical.getComponent(VTimeZone.VTIMEZONE) as VTimeZone

        assertEquals("Europe/Berlin", vTZ.timeZoneId.value)
        assertEquals(vTZ.observances.first(), vTZ.getApplicableObservance(Date("20180403")))

        val vEvent = ical.getComponent(VEvent.VEVENT) as VEvent
        val start = vEvent.startDate
        assertEquals(vTZ, start.timeZone.vTimeZone)
        assertEquals(1522738800000L, start.date.time)
    }

the test fails. start.date is always 20180402T230000 (start.date.time = 1522702800000L) instead of 20180403T090000 (start.date.time = 1522738800000L).

When the VTIMEZONE is edited so there’s a STANDARD component, it works (even if it does not apply, I have set it to 2020 here):

BEGIN:VCALENDAR
VERSION:2.0
BEGIN:VTIMEZONE
TZID:Europe/Berlin
BEGIN:DAYLIGHT
TZOFFSETFROM:+0100
TZOFFSETTO:+0200
DTSTART:20180325T030000
TZNAME:CEST
END:DAYLIGHT
BEGIN:STANDARD
TZOFFSETFROM:+0200
TZOFFSETTO:+0100
DTSTART:20200325T030000
END:STANDARD
END:VTIMEZONE
BEGIN:VEVENT
UID:only-dst@example.com 
DTSTAMP:20180329T084939Z
DTSTART;TZID=Europe/Berlin:20180403T090000
DTEND;TZID=Europe/Berlin:20180403T101500
SUMMARY:Sample Event
CREATED:20180329T084939Z
LAST-MODIFIED:20180329T084939Z
END:VEVENT
END:VCALENDAR

results in dtStart = 20180403T090000 Europe/Berlin (UNIX time 1522702800000), as expected.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
benfortunacommented, Jul 8, 2019

Just released ical4j 2.2.5 with a potential fix for this. Appreciate any feedback/confirmation of this fix. Many thanks.

1reaction
benfortunacommented, Aug 7, 2019

Apologies I thought I had also released in 3.x branch. Will make a release including the fix shortly.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to parse the VTIMEZONE definition of an iCal to a ...
For this, I first have to convert the time zone embedded in the iCal into a Nodatime type. My question is: Can the...
Read more >
Working with Time Zones - W3C
Abstract. This document contains guidelines and best practices for working with time and time zones in applications and document formats.
Read more >
datetime — Basic date and time types — Python 3.11.1 ...
Date and time objects may be categorized as “aware” or “naive” depending on whether or not they include timezone information. With sufficient knowledge...
Read more >
Formatting and parsing dateTimes as strings - IBM
This section gives information on how you can specify the dateTime format using a string of pattern letters.
Read more >
How to handle Time Zones in JavaScript - Bits and Pieces
ISOString — It can parse a text containing any time zone's numeric UTC offset. The output Date object does not keep the original...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found