Menu

getDateIterator TimeZone

Mickaël
2014-12-03
2014-12-09
  • Mickaël

    Mickaël - 2014-12-03

    Hello,

    Firstly thank you for your work,

    I am testing RecurrenceRule object and in RecurrenceProperty there is in the method getDateIterator this :

    RecurrenceIteratorFactory.createRecurrenceIterator(rruleValue, dtstartValue, TimeZone.getDefault());

    Because of TimeZone.getDefault() for DTSTART:20130610T120000Z
    event.getDateStart().getValue() gives
    2013-06-10T12:00:00Z
    and
    event.getRecurrenceRule().getDateIterator(event.getDateStart().getValue()).next() gives
    2013-06-10T10:00:00Z

    May be a timezone parameter is missing in the getDateIterator ?

    Thanks.

    String str =
                "BEGIN:VCALENDAR\r\n" +
                  "VERSION:2.0\r\n" +
                  "PRODID:-//Microsoft Corporation//Outlook 14.0 MIMEDIR//EN\r\n" +
                  "BEGIN:VEVENT\r\n" +
                    "UID:0123\r\n" +
                    "DTSTAMP:20130601T080000Z\r\n" +
                    "SUMMARY;LANGUAGE=en-us:Team Meeting\r\n" +
                    "DTSTART:20130610T120000Z\r\n" +
                    "RRULE:FREQ=WEEKLY;INTERVAL=2\r\n" +
                  "END:VEVENT\r\n" +
                "END:VCALENDAR\r\n";
    
    ICalendar c =  Biweekly.parse(str).first();
    
    
    
        VEvent event = c.getEvents().get(0);
    
        assertEquals("DTSTART doit être correct", 
                Instant.parse("2013-06-10T12:00:00Z"),
                event.getDateStart().getValue().toInstant());
    
        DateIterator dateIterator = event.getRecurrenceRule().getDateIterator(event.getDateStart().getValue());
        assertEquals("La première occurence doit être", 
                Instant.parse("2013-06-10T12:00:00Z"),
                dateIterator.next().toInstant());
    
        assertEquals("La seconde occurence doit être", 
                Instant.parse("2013-06-10T12:00:00Z"),
                dateIterator.next().toInstant());
    
     

    Last edit: Mickaël 2014-12-03
  • Michael Angstadt

    No, it's a bug. You shouldn't need to pass a timezone into the "getDateIterator()" method. The problem is that it's using the raw date/time components from the date string to create the date iterator instead of the actual timestamp. I've fixed it in this commit. Thanks for reporting this!

    Workaround: Create a copy of the DTSTART value as shown below, then pass it into the getDateIterator() method:

    :::java
    ICalDate start = event.getDateStart().getValue();
    ICalDate startCopy = new ICalDate(start, null, start.hasTime());
    DateIterator dateIterator = event.getRecurrenceRule().getDateIterator(startCopy);
    
     

Anonymous
Anonymous

Add attachments
Cancel