how about: --- #!/usr/bin/perl use strict; use warnings; use DateTime::Format::ICal;
# A file is to be processed if it arrives on the system anytime # between Friday midnight and Wednesday 8:00 pm. my $ical_start = 'FREQ=WEEKLY;BYDAY=SA;BYHOUR=0'; my $ical_end = 'FREQ=WEEKLY;BYDAY=WE;BYHOUR=8'; my $dt_set = DateTime::SpanSet->from_sets( start_set => DateTime::Format::ICal->parse_recurrence( recurrence => $ical_start ), end_set => DateTime::Format::ICal->parse_recurrence( recurrence => $ical_end ) ); my $dt = DateTime->new( year => 2010, month => 1, day => 4, ); $dt_set->contains( $dt ) ? print "$dt is in range\n" : print "$dt is not in range\n"; $dt = DateTime->new( year => 2010, month => 1, day => 8, ); $dt_set->contains( $dt ) ? print "$dt is in range\n" : print "$dt is not in range\n"; --- Flávio S. Glock 2010/1/3 James E Keenan <jk...@verizon.net>: > > The attached file, zinspan.pl, is my first attempt at using DateTime to > solve a practical problem. I am looking for feedback both on the program's > validity and on whether there is the making of a new DateTime module in it. > > Problem: Suppose that a 'week' can begin at an arbitrarily chosen day of > the week and time of day. Suppose further that that week can be divided > into two subspans: one in which an event is permitted to occur, and the > other in which the event is not permitted to occur. Write a function that > returns true if the event's date is in the permitted subspan and false if it > is in the forbidden subspan. > > Example: A file is to be processed if it arrives on the system anytime > between Friday midnight and Wednesday 8:00 pm. The file has arrived. Is it > okay to process it? > > Thank you very much. > Jim Keenan