desertrat has asked for the wisdom of the Perl Monks concerning the following question:
I'm trying to use Date::Manip::Recur to generate a list of dates for a room scheduling application, and I'm having trouble getting it to work correctly.
Per the docs, there's an OO way and a functional way of doing this.
The functional way works:
#!/usr/bin/perl use Date::Manip; @date = ParseRecur("0:0:1*1,3,5:0:0:0","May 25 2010","6/1/2010","8/30/ +2010");# every MWF between the two dates. foreach $i (@date){ print "The date is $i\n"; } exit;
results in:
The date is 2010060200:00:00 The date is 2010060400:00:00 The date is 2010060700:00:00 The date is 2010060900:00:00 The date is 2010061100:00:00 The date is 2010061400:00:00 The date is 2010061600:00:00 The date is 2010061800:00:00 The date is 2010062100:00:00
and so on.
But
#!/usr/bin/perl use Date::Manip; print "Starting....\n"; $recur = new Date::Manip::Recur; $start = $recur->new_date(); $end = $recur->new_date(); $base = $recur->new_date(); $err=$start->parse("Jun 1 2010"); print "start err is $err \n"; $err=$end->parse("Aug 30 2010"); print "end err is $err \n"; $err=$base->parse("May 25 2010"); print "base err is $err \n"; $err=$recur->frequency("0:0:1*1,3,5:0:0:0"); print "freq err is $err \n"; @date = $recur->dates(); print "dates err is $err \n"; foreach $i (@date){ print "The date is $i\n"; } exit;
gives me:
Starting.... start err is 0 end err is 0 base err is 0 freq err is 0 dates err is 0
And nothing more.
I cannot even get the OO example given in the docs to work.
anyone here used this, and can point out my no doubt boneheaded mistake, before I bug the author?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Date::Manip::Recur is not returning a list
by andreas1234567 (Vicar) on Jun 24, 2010 at 19:34 UTC | |
by desertrat (Sexton) on Jun 24, 2010 at 21:19 UTC | |
by almut (Canon) on Jun 24, 2010 at 21:28 UTC | |
by desertrat (Sexton) on Jun 24, 2010 at 22:38 UTC |