Time-Local - Day '31' out of range 1..30

Posted on Thu Aug 31 17:51:30 2006 by realmelancon
Day '31' out of range 1..30
Hello, I have a simple function that converts date, time in epoch format, and it fails when I use 31 as day. See excerpt:
#!/usr/bin/perl #-------------------------------------------------------------------------- use Time::Local; print "\n\n".time2sec("2006/10/31","11:00:01"); print "\n"; exit; sub time2sec { #------------- converts date+time to second ------ # e.g. time2sec("2006/03/10","11:00:01"); ($date, $time) = @_; $year = substr($date,0,4); $mon = substr($date,5,2); $mday = substr($date,8,2); $hours = substr($time,0,2); $min = substr($time,3,2); $sec = substr($time,6,2); $STIME=""; if ($mon > 0) { $STIME = timelocal($sec, $min, $hours, $mday, $mon, $year); } return $STIME; }
FYI, I have installed latest Time-Local-1.13.tar.gz and I still get the same error. If I use 30 as day it works... But all months with 31 days fail. Message is: Day '31' out of range 1..30 Any help would be appreciated. Thanks. Real Melancon.
Direct Responses: 3083 | 3084 | Write a response