I ran into some strange behaviour using Date::Manip 6.40 on perl 5.12.4 in Fedora 14 and I'm wondering if anyone has any thoughts on it.
Running the following code:
#!/usr/bin/perl
use strict;
use Date::Manip;
Date_Init("TZ=+0930");
my $localtime = "1349541878";
printf("%s:%s:%s\n", $localtime, scalar localtime( $localtime ), UnixD
+ate( scalar localtime( $localtime ), qq{%Y-%m-%d %H:%M:%S} ) );
$localtime = "1362112603";
printf("%s:%s:%s\n", $localtime, scalar localtime( $localtime ), UnixD
+ate( scalar localtime( $localtime ), qq{%Y-%m-%d %H:%M:%S} ) );
Returns:
WARNING: [printf] Object must contain a valid date
Missing argument in printf at /tmp/time.pl line 8.
1349541878:Sun Oct 7 02:14:38 2012:
1362112603:Fri Mar 1 14:06:43 2013:2013-03-01 14:06:43
Now, that's a real time zone (Australian Central Standard Time), in case anyone was wondering.
- The same problem occurs if the Date_Init("TZ=+0930"); directive to Date_Init("TZ=+1000"); (Australian Eastern Standard Time)
- The correct timestamp is returned if I change the Date_Init("TZ=+0930"); directive to Date_Init("TZ=+0900"); (Japan Standard Time)
- The correct timestamp is returned if I remove the Date_Init("TZ=+0930"); directive.
- The message isn't reported the several thousand other times I tested with when parsing several years worth of log files (there's a lot of possible times in the universe, so bear with me for not testing them all ;) )
Anyone have any insight into this issue?
The error was originally experienced on Date::Manip 6.22, upgrading to 6.40 removed the WARNING message, but reproduced the same behaviour.
Now, I don't need to resolve the issue, but am interested in understanding it. I appreciate any info.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.