Posted on 2006-09-18 21:50:06-07 by methylal in response to 2881
Re: Day '31' out of range 1..30
Looking at the module:

You will see that Months are set in an array:
my @MonthDays = (31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);

Therefore, when it tries to pull the number of days for the month you passed to it, it's searching it's index from 0 to 11. So when you pass in your Month as 10 (October), it's searching the array and thinking only 30 days are avilable and failing when you specify 31 since you are technically 'out of range'.

Three solutions:
1) Subtract 1 from your month before passing it into the Time::timelocal method
2) Just open up your Local.pm file and in the subroutine (timegm), look for the following:
my $md = $MonthDays[$month];
and subtract 1 from $month... so:
my $md = $MonthDays[$month-1];
3) Use DateTime::Precise instead.

--meth
Direct Responses: Write a response
Perl Weekly newsletter
A free weekly newsletter for people who are busy to read all the blogs. click here to check it out.