It is not a bug, but it depends on what you expect the first week of the month to be. You can play with the 'week_start_day' parameter to get the right week.
The module DateTime::Event::ICal is probably a better choice for you, since it defaults to the behaviour you expect: --- use DateTime::Event::ICal; my ($start) = 1257051600; my ($end) = 1283058000; my ($start_dt) = DateTime->from_epoch(epoch => $start); my ($end_dt) = DateTime->from_epoch(epoch => $end); my ($set) = DateTime::Event::ICal->recur(freq => 'monthly', byday => ['2tu']); my ($iterator) = $set->iterator(start => $start_dt, end => $end_dt); while (my $dt = $iterator->next) { printf "%s (%s)\n", scalar gmtime $dt->epoch, $dt->weekday_of_month; } --- Tue Nov 10 00:00:00 2009 (2) Tue Dec 8 00:00:00 2009 (2) Tue Jan 12 00:00:00 2010 (2) Tue Feb 9 00:00:00 2010 (2) Tue Mar 9 00:00:00 2010 (2) Tue Apr 13 00:00:00 2010 (2) Tue May 11 00:00:00 2010 (2) Tue Jun 8 00:00:00 2010 (2) Tue Jul 13 00:00:00 2010 (2) Tue Aug 10 00:00:00 2010 (2) 2009/12/18 Frank Sheiness <synde...@gmail.com>: > Hello, > > The manpage provides the example: > # second tuesday of every month > my $set = DateTime::Event::Recurrence->monthly( weeks => 2, days => 2 ); > > However, if I do this: > > use DateTime::Event::Recurrence; > > my ($start) = 1257051600; > my ($end) = 1283058000; > my ($start_dt) = DateTime->from_epoch(epoch => $start); > my ($end_dt) = DateTime->from_epoch(epoch => $end); > > my ($set) = DateTime::Event::Recurrence->monthly(weeks => 2, days => 2); > > my ($iterator) = $set->iterator(start => $start_dt, end => $end_dt); > > while (my $dt = $iterator->next) { > printf "%s (%s)\n", scalar gmtime $dt->epoch, $dt->weekday_of_month; > } > > I get the following output: > > Tue Nov 10 00:00:00 2009 (2) > Tue Dec 15 00:00:00 2009 (3) > Tue Jan 12 00:00:00 2010 (2) > Tue Feb 9 00:00:00 2010 (2) > Tue Mar 9 00:00:00 2010 (2) > Tue Apr 13 00:00:00 2010 (2) > Tue May 11 00:00:00 2010 (2) > Tue Jun 15 00:00:00 2010 (3) > Tue Jul 13 00:00:00 2010 (2) > Tue Aug 10 00:00:00 2010 (2) > > In December and June (months that begin on Tuesday), the event shows up on > the third weekday of the month instead of the second. Note that you get the > same behavior for any value of "days" in the set. If I use 3 for Wednesday, > I'll get the second Wednesday except for months that begin on Tuesday. Is > this a bug or am I doing something incorrectly? I'm using D::E::R v0.16. > > Thanks, > Frank >