ParseRecur from Date::Manip

A

Arndt, Tobias

Hi NG,

trying to understand the ParseRecur function. Seems to be too complex
for me. My goal is to get the first Monday from each month of the year
2003. My code:

@date = ParseRecur("0:1*1:1:0:0:0","1/1/03","1/1/03","31/12/03");

print $date[3];

# that should print out the First Monday in April 2003

But I get 2003040700:00:00 !! That's the second Monday in this
month.... :-(
Maybe I didn't get the meaning of the three ($base etc..)variables
from the example;

# To find the 2nd tuesday of every month
# @date = ParseRecur("0:1*2:2:0:0:0",$base,$start,$stop);

Any help or hint would be greatly appreciated !

Thanks Tobias
 
K

Kien Ha

Hi NG,

trying to understand the ParseRecur function. Seems to be too complex
for me. My goal is to get the first Monday from each month of the year
2003. My code:

@date = ParseRecur("0:1*1:1:0:0:0","1/1/03","1/1/03","31/12/03");
you wouldn't get any output for @date because of ^^ ^^
@date = ParseRecur("0:1*1:1:0:0:0","1/1/03","1/1/03","12/31/03");
print $date[3];

# that should print out the First Monday in April 2003

But I get 2003040700:00:00 !! That's the second Monday in this
month.... :-(
No, that's 1st Monday of April, 2003.

print UnixDate( $date[3], "%a. %b %d, %Y\n");
=> Mon. Apr 07, 2003

Maybe I didn't get the meaning of the three ($base etc..)variables
from the example;

# To find the 2nd tuesday of every month
# @date = ParseRecur("0:1*2:2:0:0:0",$base,$start,$stop);

my $format = "%a. %b %d, %Y\n";
my ($base, $start, $stop ) = qw(1/1/03 1/1/03 12/31/03);
print map UnixDate($_, $format),
ParseRecur("0:1*2:2:0:0:0", $base, $start, $stop);

or verbally, you could do:

print map UnixDate($_, $format),
ParseRecur("2nd tuesday of every month in 2003");


--
 
J

Jacob Heider

Hi NG,

trying to understand the ParseRecur function. Seems to be too complex
for me. My goal is to get the first Monday from each month of the year
2003. My code:

@date = ParseRecur("0:1*1:1:0:0:0","1/1/03","1/1/03","31/12/03");

print $date[3];

# that should print out the First Monday in April 2003

But I get 2003040700:00:00 !! That's the second Monday in this
month.... :-(

How can the 7th be the second Monday? Monday, April the 0th?

Jacob
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,185
Members
46,736
Latest member
AdolphBig6

Latest Threads

Top