Scheduling FAQ?

2006-05-16 Thread Jerrad Pierce
What's the best way to iterate over Mondays, Tuesdays, and Thursdays between
two dates?I checked the site and list archives but found nothing. My hunch is:

  my $days = DateTime::Event::Recurrence-weekly( days = [1,2,4],
  start=$DT1);
  my $iter = $days-iterator;

  while( (my $day = $iter-next)  $DT2 ){
...
  }

However, it seems it ought to be possible to use some simple combination of
modules (that eludes me) to handle all the logic. (I like elegant)


Also, for the listed FAQ: How do I calculate the number of the week of month
the given date lies in?

Wouldn't it be easier to simply see what week number the first of the month is?
If it's zero return the ISO week number +1, other return the ISO week number.
Or is there some subtlety I'm missing? If not, I think this is easier to
understand.
-- 
H4sICNoBwDoAA3NpZwA9jbsNwDAIRHumuC4NklvXTOD0KSJEnwU8fHz4Q8M9i3sGzkS7BBrm
OkCTwsycb4S3DloZuMIYeXpLFqw5LaMhXC2ymhreVXNWMw9YGuAYdfmAbwomoPSyFJuFn2x8
Opr8bBBidcc=
--
MOTD on Sweetmorn, the 63rd of Discord, in the YOLD 3172:
...and grenades are also useful for digging foxholes, removing unwanted 
shrubbery, unclogging drains... --Axly's Book of Explosives for Pyromaniacs


Re: Scheduling FAQ?

2006-05-16 Thread Jerrad Pierce
Hmm, it's not even as simple as that... as I just (re)noticed the dox state

 This specifies a recurrence that happens at 10:30 on the day specified by
 start = $dt, and then every 11 days before and after $dt.

When trying to figure out why that didn't work. Am I the only one who does
this sort of date math that seems to fall between different areas? Or am I
abusing the modules or what? It's not simply that there isn't a comprehensive
roadmap for the suite/namespace is there?
-- 
H4sICNoBwDoAA3NpZwA9jbsNwDAIRHumuC4NklvXTOD0KSJEnwU8fHz4Q8M9i3sGzkS7BBrm
OkCTwsycb4S3DloZuMIYeXpLFqw5LaMhXC2ymhreVXNWMw9YGuAYdfmAbwomoPSyFJuFn2x8
Opr8bBBidcc=
--
MOTD on Sweetmorn, the 63rd of Discord, in the YOLD 3172:
...and grenades are also useful for digging foxholes, removing unwanted 
shrubbery, unclogging drains... --Axly's Book of Explosives for Pyromaniacs


Re: Scheduling FAQ?

2006-05-16 Thread Flavio S. Glock

2006/5/16, Jerrad Pierce [EMAIL PROTECTED]:

What's the best way to iterate over Mondays, Tuesdays, and Thursdays between
two dates?


For some value of best:

---
use DateTime::Event::ICal;

my $dt1 = DateTime-today;
my $dt2 = $dt1-clone-add( months = 1 );

print interval: $dt1 $dt2\n;

my $set = DateTime::Event::ICal-recur(
  dtstart = $dt1,
  until   = $dt2,
  freq ='weekly',
  byday = [ 'mo', 'tu', 'th' ],
);

my @days = $set-as_list;
print days as list: @days\n;

print days as iterator: ;
my $iter = $set-iterator;
while ( my $dt = $iter-next ) {
 print ' ', $dt-datetime;
}

---

- Flavio S. Glock


Re: Scheduling FAQ?

2006-05-16 Thread Jerrad Pierce
Ah yes, of course. 

Thanks!

FWIW the goal is to determine the average percentage of time each several
rooms is occupied for a given period/set of records on an hour by hour basis
over a week. Doesn't that sound like fun?
-- 
H4sICNoBwDoAA3NpZwA9jbsNwDAIRHumuC4NklvXTOD0KSJEnwU8fHz4Q8M9i3sGzkS7BBrm
OkCTwsycb4S3DloZuMIYeXpLFqw5LaMhXC2ymhreVXNWMw9YGuAYdfmAbwomoPSyFJuFn2x8
Opr8bBBidcc=
--
MOTD on Sweetmorn, the 63rd of Discord, in the YOLD 3172:
...and grenades are also useful for digging foxholes, removing unwanted 
shrubbery, unclogging drains... --Axly's Book of Explosives for Pyromaniacs