dlemmermann / google-rfc-2445

Automatically exported from code.google.com/p/google-rfc-2445
Apache License 2.0
1 stars 0 forks source link

DateTimeIterator.advanceTo() method skips a date for monthly 'bysetpos' rData #13

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
I am truely greateful for a wonderful library. I have a bug to report. 

    @Test
    public void reproduceAdanceToMethodBug() throws ParseException {
        // given
        String rData = "RRULE:FREQ=MONTHLY;INTERVAL=1;BYDAY=TU;BYSETPOS=4";
        DateTime recurrenceStart = new DateTime(2015, 2, 20, 0, 0, 0, 0, DateTimeZone.UTC);
        DateTime skipBefore = new DateTime(2015, 4, 20, 0, 0, 0, 0, DateTimeZone.UTC);        
        DateTimeIterator iterator = DateTimeIteratorFactory.createDateTimeIterable(rData, recurrenceStart, recurrenceStart.getZone(), true).iterator();

        // when
        iterator.advanceTo(skipBefore);

        // then
        assertThat(iterator.next(), is(new DateTime(2015, 4, 28, 0, 0, 0, 0, DateTimeZone.UTC)));
    }

Test case above results in AssertionErrror. 

java.lang.AssertionError: 
Expected: is <2015-04-28T00:00:00.000Z>
     but: was <2015-05-26T00:00:00.000Z>

DateTimeIterator.advanceTo() method skips 2015-04-28T00:00:00. 
It seems to work correctly with rData without 'FREQ=MONTHLY + BYSETPOS' 
combination.

Original issue reported on code.google.com by ryej...@gmail.com on 4 May 2015 at 8:08