dongmin-shin/google-rfc-2445

Yearly recurrences

Opened this issue · 1 comments

What steps will reproduce the problem?
1. Just running this test method : 

    public static void testsICAL(){
        String iCal = "RRULE:FREQ=YEARLY;INTERVAL=2;BYDAY=SA;BYMONTH=9;BYSETPOS=1";

        SimpleDateFormat datePatternUTC = new SimpleDateFormat(DATE_PATTERN_API);
        datePatternUTC.setTimeZone(TimeZone.getTimeZone("UTC"));
        String sDateStart="2013-08-31T06:00:20.000";
        String sDateAdvanceTo="2013-10-01T00:00:00.000";
        Calendar cStart = Calendar.getInstance();
        Calendar cAdvanceTo= Calendar.getInstance();        

        try {
            cStart.setTime(datePatternUTC.parse(sDateStart));
            cAdvanceTo.setTime(datePatternUTC.parse(sDateAdvanceTo));
        } catch (ParseException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        DateTime start = new DateTime(cStart.getTimeInMillis());
        DateTime advanceTo = new DateTime(cAdvanceTo.getTimeInMillis());

        try {
            DateTimeIterator it = com.google.ical.compat.jodatime.DateTimeIteratorFactory.createDateTimeIterator(iCal, start, DateTimeZone.forID("Europe/Paris"), true);
            if (it != null){
                // On avance l'iterateur jusqua la date de debut de liste
                it.advanceTo(advanceTo);
                Date date;
                int i = 0;
                while(i<=5 && it.hasNext()) {
                    date=it.next().toDate();
                    System.out.println("date: "+date);
                    i++;
                }
            }
        } catch (ParseException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }


What is the expected output? What do you see instead?

I want to get the first Saturday of September, every two year. 
I want the list begin after : 2013-10-01T00:00:00.000.

Expected : 
date: Sat Sep 05 08:00:20 CEST 2015
date: Sat Sep 02 08:00:20 CEST 2017
date: Sat Sep 07 08:00:20 CEST 2019
date: Sat Sep 04 08:00:20 CEST 2021
date: Sat Sep 02 08:00:20 CEST 2023

See instead : 
date: Sat Sep 02 08:00:20 CEST 2017
date: Sat Sep 07 08:00:20 CEST 2019
date: Sat Sep 04 08:00:20 CEST 2021
date: Sat Sep 02 08:00:20 CEST 2023
date: Sat Sep 06 08:00:20 CEST 2025

The 2015 occurrence is ommited.

What version of the product are you using?
rfc2445-4Mar2011.jar 

Please provide any additional information below.
The problem does not occurs if I set : 
   sDateAdvanceTo="2013-09-30T00:00:00.000";


Original issue reported on code.google.com by perrine1...@gmail.com on 26 Sep 2014 at 7:37

The problem does not occurs if I set : 
 sDateStart="2013-09-07T06:00:20.000";
and
 iCal = "RRULE:FREQ=YEARLY;INTERVAL=2;BYDAY=SA;BYSETPOS=1";
(iCal is the same without BYMONTH=9;)

Original comment by perrine1...@gmail.com on 26 Sep 2014 at 9:35