I'm using Date::Manip for a variety of things, and want to开发者_StackOverflow create an array of days of the month. I think I need:
@date = &ParseRecur("2010:4:0:0:0:0:0");
but, it doesn't do it. I've read & reread the man page but can't get the syntax.
@date = &ParseRecur("2010:4:0:1:0:0:0");
@date = &ParseRecur("2010:4:0:1*:0:0:0");
don't work either!
You could build the list with your own loop, instead of using ParseRecur.
$month = 4;
for ($day = 1; $day <= 31; $day++) {
my $date = UnixDate( "$month/$day/2010", "%m-%d-%Y" );
push( @list, $date ) if (defined $date);
}
From the man pages: "There are a small handful of English strings which can be parsed in place of a numerical recur description." Check out the examples in the man page.
So, if you want an array of days of a month - say for June in 2010 you would do:
@dates = ParseRecur("every day in June 2010");
精彩评论