The behavior of DateTime::Event::ICal->recur appears to be inconsistent with
RRULE: FREQ=weekly;INTERVAL=2 when dtStart is Sunday.

 

The logic for all start days other than Sunday appears to be:

If dtStart is equal to byday, the first day in the set is dtStart 

If dtStart is < than byday, the first day in the set is the very next
occurrence of byday

If dtStart is > than byday, the first day in the set is the occurrence of
byday in the 2nd week after dtStart

 

However, for Sunday, it appears that the rules are:

Regardless of where dtStart falls in the week, the first day in the set is
the very next occurrence of byday after dtStart

 

DTSTART: 2004-07-03 (Saturday Start)

RRULE:FREQ=weekly;INTERVAL=2;BYDAY=mo;

2004-07-12

2004-07-26

2004-08-09

RRULE:FREQ=weekly;INTERVAL=2;BYDAY=fr;

2004-07-16

2004-07-30

2004-08-13

RRULE:FREQ=weekly;INTERVAL=2;BYDAY=sa;

2004-07-03

2004-07-17

2004-07-31

RRULE:FREQ=weekly;INTERVAL=2;BYDAY=su;

2004-07-04

2004-07-18

2004-08-01

 

DTSTART: 2004-07-04 (Sunday Start)

RRULE:FREQ=weekly;INTERVAL=2;BYDAY=mo;

2004-07-05

2004-07-19

2004-08-02

RRULE:FREQ=weekly;INTERVAL=2;BYDAY=fr;

2004-07-09

2004-07-23

2004-08-06

RRULE:FREQ=weekly;INTERVAL=2;BYDAY=sa;

2004-07-10

2004-07-24

2004-08-07

RRULE:FREQ=weekly;INTERVAL=2;BYDAY=su;

2004-07-11

2004-07-25

2004-08-08

 

#!/usr/local/bin/perl

 

use strict;

use DateTime;

use DateTime::Event::ICal;

 

my $startDate;

 

for my $day ( 3 .. 4) {

    my $dtStart = DateTime->new( year => 2004,

                                 month => 7,

                                 day => $day,

                                 time_zone => 'GMT' );

 

    print "DTSTART: " . $dtStart->ymd . "\n";

    for my $day ('mo','tu','we','th','fr','sa','su') {

        print "RRULE:FREQ=weekly;INTERVAL=2;BYDAY=$day;\n";

        my $set = DateTime::Event::ICal->recur( dtstart => $dtStart,

                                                                      count
=> 3,

                                                                      freq
=> 'weekly',

 
interval => 2,

                                                                      byday
=> [ $day ],

                                                                     );

 

        my $iter = $set->iterator;

        while ( my $dt = $iter->next ) {

            print $dt->ymd . "\n";

        }

    }

}

 

 

Thanks.

Bridget Almas

Ovid Technologies

 

Reply via email to