mangstadt / biweekly

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

Recurrence iterators for all-day events include a time component #47

Closed mangstadt closed 8 years ago

mangstadt commented 8 years ago

The attached iCalendar file contains an all-day event (the DTSTART is a "date" as opposed to a "date/time"). When outputting its dates generated by a recurrence iterator, the dates have a time component. But they should not have time components because it is an all-day event.

Code:

ICalReader reader = new ICalReader(new File("Test_obalqpctbh1c4f66r683opue5g@group.calendar.google.com.ics"));
ICalendar ical = reader.readNext();
VEvent event = ical.getEvents().get(1);

System.out.println("Start: " + event.getDateStart().getValue());
DateIterator iterator = event.getDateIterator(TimeZone.getDefault());

int count = 0;
while (iterator.hasNext()) {
    if (++count == 10) break;
    final Date date = iterator.next();
    System.out.println(date);
}

Output:

Start: Mon Jun 06 00:00:00 EDT 2016
Sun Jun 05 20:00:00 EDT 2016
Sun Jun 19 20:00:00 EDT 2016
Sun Jul 03 20:00:00 EDT 2016
Sun Jul 17 20:00:00 EDT 2016
Sun Jul 31 20:00:00 EDT 2016
Sun Aug 14 20:00:00 EDT 2016
Sun Aug 28 20:00:00 EDT 2016
Sun Sep 11 20:00:00 EDT 2016
Sun Sep 25 20:00:00 EDT 2016

Test_obalqpctbh1c4f66r683opue5g@group.calendar.google.com.ics.txt

mangstadt commented 8 years ago

Fixed in 8a7153017ef906f4f7b985fa1799e8953e5bc22d.