Is that a generic business calculation or just an application of sets?

I think the latter.  You can just make a set representing the
intersection of mondays (or weekdays) and Dec. 31sts.  Then iterate
over it (using the restricted time range) to find the solution.

--
use strict;
use DateTime;
use DateTime::Event::Recurrence;

my $dec32   = DateTime::Event::Recurrence->yearly
                (months => 12, days => 31);
my $mondays = DateTime::Event::Recurrence->weekly
                (days   => 1);
my $s = $dec32->intersection($mondays);

my $i = $s->iterator(start => DateTime->new(year => 2000),
                     end   => DateTime->new(year => 2008));
while (my $d = $i->next) {
    printf "%s - %s\n", $d->day_name(), $d->datetime;
}
--

Prints:
--
Monday - 2001-12-31T00:00:00
Monday - 2007-12-31T00:00:00
--

          -ben

On Tue, Jun 17, 2003 at 01:39:00PM -1000, Joshua Hoblitt wrote:
> What if I wanted to know inside a range of years which had a December 31st that was 
> on a Monday (or on a weekday)?
> 
> -J
> 
> --

Reply via email to