Rabenschwinge has asked for the wisdom of the Perl Monks concerning the following question:

I have a strange problem here. It seems that according to timegm from Time::Local there was no August 31 in 2009: The following three lines of code produce the output right after it:
use Time::Local; (...) next unless (m{^(\d{4})-(\d\d)-(\d\d)$}); print "$3.$2.$1\n"; $next = timegm(0,0,0,$3,$2,$1-1900);
Output:
31.08.2009 Day '31' out of range 1..30 at /home/bjoern/bin/search.pl line 18
Could anyone explain that please?

Replies are listed 'Best First'.
Re: timegm: There is no August, 31 in 2009
by Corion (Patriarch) on Jul 21, 2010 at 10:57 UTC

    See Time::Local, emphasis by me:

    It is worth drawing particular attention to the expected ranges for the values provided. The value for the day of the month is the actual day (ie 1..31), while the month is the number of months since January (0..11). This is consistent with the values returned from localtime() and gmtime().
Re: timegm: There is no August, 31 in 2009
by duelafn (Parson) on Jul 21, 2010 at 10:58 UTC

    August = 7 ... as in localtime

    Good Day,
        Dean

Re: timegm: There is no August, 31 in 2009
by tlhackque (Beadle) on Jul 24, 2010 at 19:00 UTC
    September has no day 31.
    perldoc -f Time::Local It is worth drawing particular attention to the expected ranges for t +he values provided. The value for the day of the month is the actual day (ie 1..31), while the month is the numb +er of months since January (0..11). This is consistent with the values returned from "localtime()" and "gmtime()".
    Jan = 0, Feb = 1; Aug = 7; Sept = 8; Dec = 11.