I think timelocal() wants the year to be years since 1900 so code shoud perhaps be
my $time = timelocal(0, 0, 0, $d, $m-1, $y - 1900);
Also, for this particular application, why not set the hash up with the subtraction by one already done?
my %month_num_by_name = (
JAN => 0,
FEB => 1,
...
);
Cheers, JohnGG
Update: davorg and ikegami have pointed out that timelocal() does accept dates like 2007 without first subtracting 1900, although it does the right thing if you do the subtraction as well. ikegami also explained his excellent reason for doing the month the way he does. |