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

Time of Event not correct with Events from Wordpress Events Manager #651

Open
ArnyminerZ opened this issue Sep 4, 2023 · 5 comments
Open

Comments

@ArnyminerZ
Copy link
Contributor

Describe the bug
When using events provided from the Wordpress' Events Manager plugin, start time is parsed incorrectly.

To Reproduce
Steps to reproduce the behavior:

  1. Try parsing the following ical:

    BEGIN:VCALENDAR
    VERSION:2.0
    BEGIN:VEVENT
    UID:xxx@xxx.de
    DTSTART;TZID=Europe/Berlin:20230905T200000
    DTEND;TZID=Europe/Berlin:20230905T210000
    SUMMARY:xxxxxxxxxxxxxxxxxxx
    END:VEVENT
    BEGIN:VTIMEZONE
    TZID:Europe/Berlin
    BEGIN:DAYLIGHT
    DTSTART:20230326T030000
    TZOFFSETFROM:+0100
    TZOFFSETTO:+0200
    TZNAME:CEST
    END:DAYLIGHT
    BEGIN:STANDARD
    DTSTART:20231029T020000
    TZOFFSETFROM:+0200
    TZOFFSETTO:+0100
    TZNAME:CET
    END:STANDARD
    BEGIN:DAYLIGHT
    DTSTART:20240331T030000
    TZOFFSETFROM:+0100
    TZOFFSETTO:+0200
    TZNAME:CEST
    END:DAYLIGHT
    BEGIN:STANDARD
    DTSTART:20241027T020000
    TZOFFSETFROM:+0200
    TZOFFSETTO:+0100
    TZNAME:CET
    END:STANDARD
    END:VTIMEZONE
    END:VCALENDAR
    
  2. Example test code:

    import net.fortuna.ical4j.data.CalendarBuilder
    import net.fortuna.ical4j.model.Component
    import net.fortuna.ical4j.model.component.VEvent
    import org.junit.Test
    import java.io.StringReader
    
    class WordpressEventsManagerTest {
        @Test
        fun test_parsing() {
            val calendar = CalendarBuilder().build(
                StringReader(
                    "BEGIN:VCALENDAR\n" +
                        "VERSION:2.0\n" +
                        "BEGIN:VEVENT\n" +
                        "UID:xxx@xxx.de\n" +
                        "DTSTART;TZID=Europe/Berlin:20230905T200000\n" +
                        "DTEND;TZID=Europe/Berlin:20230905T210000\n" +
                        "SUMMARY:xxxxxxxxxxxxxxxxxxx\n" +
                        "END:VEVENT\n" +
                        "BEGIN:VTIMEZONE\n" +
                        "TZID:Europe/Berlin\n" +
                        "BEGIN:DAYLIGHT\n" +
                        "DTSTART:20230326T030000\n" +
                        "TZOFFSETFROM:+0100\n" +
                        "TZOFFSETTO:+0200\n" +
                        "TZNAME:CEST\n" +
                        "END:DAYLIGHT\n" +
                        "BEGIN:STANDARD\n" +
                        "DTSTART:20231029T020000\n" +
                        "TZOFFSETFROM:+0200\n" +
                        "TZOFFSETTO:+0100\n" +
                        "TZNAME:CET\n" +
                        "END:STANDARD\n" +
                        "BEGIN:DAYLIGHT\n" +
                        "DTSTART:20240331T030000\n" +
                        "TZOFFSETFROM:+0100\n" +
                        "TZOFFSETTO:+0200\n" +
                        "TZNAME:CEST\n" +
                        "END:DAYLIGHT\n" +
                        "BEGIN:STANDARD\n" +
                        "DTSTART:20241027T020000\n" +
                        "TZOFFSETFROM:+0200\n" +
                        "TZOFFSETTO:+0100\n" +
                        "TZNAME:CET\n" +
                        "END:STANDARD\n" +
                        "END:VTIMEZONE\n" +
                        "END:VCALENDAR"
                )
            )
    
            val event = calendar.getComponent<VEvent>(Component.VEVENT)
            assert(event.startDate.value == "20230905T200000") {
                "Start date does not match. Expected: <20230905T200000>. Actual: <${event.startDate.value}>"
            }
        }
    }
  3. Assertion fails with Start date does not match. Expected: <20230905T200000>. Actual: <20230905T010000>.

Expected behavior
DTSTART should be 20230905T200000 and not 20230905T010000

Environment (please complete the following information):

  • OS: Android
  • Java Version: 17
  • iCal4j Version: 3.2.12
@odin568
Copy link

odin568 commented Dec 12, 2023

Issue not only happening with Wordpress Events Manager, also have a case with eluceo/ical

Coming from bitfireAT/icsx5#198

@cbix
Copy link

cbix commented Mar 9, 2024

I'm observing the same issue with iCal generated by the Wordpress Event Calendar Plugin. Two calendar feeds using the Europe/Berlin timezone to validate:

@cbix
Copy link

cbix commented Mar 10, 2024

Issue seems to be related to timezone definition.
This (for example) causes the issue:

BEGIN:VTIMEZONE
TZID:Europe/Berlin
BEGIN:DAYLIGHT
TZOFFSETFROM:+0100
TZOFFSETTO:+0200
TZNAME:CEST
DTSTART:20240331T010000
END:DAYLIGHT
BEGIN:STANDARD
TZOFFSETFROM:+0200
TZOFFSETTO:+0100
TZNAME:CET
DTSTART:20241027T010000
END:STANDARD
BEGIN:DAYLIGHT
TZOFFSETFROM:+0100
TZOFFSETTO:+0200
TZNAME:CEST
DTSTART:20250330T010000
END:DAYLIGHT
BEGIN:STANDARD
TZOFFSETFROM:+0200
TZOFFSETTO:+0100
TZNAME:CET
DTSTART:20251026T010000
END:STANDARD
END:VTIMEZONE

While this works as expected:

BEGIN:VTIMEZONE
TZID:Europe/Berlin
BEGIN:DAYLIGHT
DTSTART:19810329T020000
RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=3
TZNAME:CEST
TZOFFSETFROM:+0100
TZOFFSETTO:+0200
END:DAYLIGHT
BEGIN:STANDARD
DTSTART:19961027T030000
RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=10
TZNAME:CET
TZOFFSETFROM:+0200
TZOFFSETTO:+0100
END:STANDARD
END:VTIMEZONE

@benfortuna
Copy link
Member

Issue seems to be related to timezone definition. This (for example) causes the issue:

If I'm not mistaken, that first example doesn't include any current timezone information as the DTSTART values are all in the future.

@cbix
Copy link

cbix commented Mar 11, 2024

the DTSTART values are all in the future

Good catch, I just reported this to the plugin's support forum. Seems like a few php-based generators use DateTimeZone::getTransitions($start, $end) which gives you a fixed set of tz transitions as opposed to proper rrules.

What's still weird is that while all timezone DTSTARTs are in the future, it also causes later events within those intervals to be parsed with the wrong time.

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

No branches or pull requests

4 participants