mangstadt / biweekly

biweekly is an iCalendar library written in Java.
BSD 2-Clause "Simplified" License
323 stars 44 forks source link

DateIterator does not correctly handle rrule UNTIL #99

Closed NivekAreir closed 4 years ago

NivekAreir commented 4 years ago

Hi,

I observed the following bug when using a DateIterator on an event with a rrule containing an UNTIL field

        VEvent event = new VEvent();

        DateStart start = new DateStart(Date.from(Instant.parse("2020-03-01T17:00:00Z")));
        event.setDateStart(start);

        Date until = Date.from(Instant.parse("2020-03-05T17:01:00Z"));
        Recurrence recur = new Recurrence.Builder(Frequency.DAILY).until(until).build();
        event.setRecurrenceRule(recur);

        TimeZone timezone = TimeZone.getTimeZone("America/New_York");
        DateIterator iterator = event.getDateIterator(timezone);
        while(iterator.hasNext()){
            Date startDate = iterator.next();
            System.out.println(startDate.toInstant().toString());
        }

My event has a daily frequency and starts at 17h UTC. I want to print all the occurrences before the 2020-03-05T17:01:00Z. Here is what I observe :

2020-03-01T17:00:00Z
2020-03-02T17:00:00Z
2020-03-03T17:00:00Z
2020-03-04T17:00:00Z

The last occurrence 2020-03-05T17:00:00Z is missing even if it starts before the until date. The reason of this bug is explained and fixed in #63 but the PR has been reverted.

mangstadt commented 4 years ago

@NivekAreir Thanks for reporting this. This has been a long standing issue.

PR #63 was reverted because it was breaking under the Europe/Paris time zone. ☹️

mangstadt commented 4 years ago

This issue should be fixed now. See: https://github.com/mangstadt/biweekly/pull/63#issuecomment-697933157