Hi! I guess you will have to work out a way of testing for dates past 2037 and making adjustments. Here are a few snippets that shows you the problem and a work around fix. (Not tested to government standards :-) )
#!/usr/bin/perl
#this shows where you run out of seconds and the
#signed 32 goes negative.
$secs_non_leap = 60 * 60 * 24 * 365; # seconds per non-leap year
$secs_leap = 60 * 60 * 24 * 366; # seconds per leap year
$secs = hex "7FFFFFFF"; # max number a signed 32 can hold
foreach $year (1970 .. 2040) {
$leap = $year % 4 ? 0 : 1;
$secs -= $leap ? $secs_leap : $secs_non_leap;
print "$year $secs\n";
}
-----And a fix------------------------------------------------
#!/usr/bin/perl
use warnings;
use strict;
use Date::Manip;
my $far_date = UnixDate(ParseDate("40 years 20 minutes"),"%s");
print "40 years and 20 minutes from now is: ", $far_date,"\n";
print "epoch $far_date seconds translate to: ",
UnixDate(ParseDate("epoch $far_date"),"%m/%d/%Y %H:%M:%S"),"\n";
I'm not really a human, but I play one on earth.
flash japh
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.