I'm not sure that's quite right...

sub gmtime { usage "gmtime(time)" if @_ != 1; CORE::gmtime($_[0]); }
verses
sub timegm { my ($sec,$min,$hour,$mday,$month,$year) = @_; if ($year >= 1000) { $year -= 1900; } elsif ($year < 100 and $year >= 0) { $year += ($year > $Breakpoint) ? $Century : $NextCentury; } unless ($Options{no_range_check}) { if (abs($year) >= 0x7fff) { $year += 1900; croak "Cannot handle date ($sec, $min, $hour, $mday, $month, * +$year*)"; } croak "Month '$month' out of range 0..11" if $month > 11 or $month + < 0; my $md = $MonthDays[$month]; # ++$md if $month == 1 and $year % 4 == 0 and # ($year % 100 != 0 or ($year + 1900) % 400 == 0); ++$md unless $month != 1 or $year % 4 or !($year % 400); croak "Day '$mday' out of range 1..$md" if $mday > $md or $mda +y < 1; croak "Hour '$hour' out of range 0..23" if $hour > 23 or $hou +r < 0; croak "Minute '$min' out of range 0..59" if $min > 59 or $min + < 0; croak "Second '$sec' out of range 0..59" if $sec > 59 or $sec + < 0; } my $days = _daygm(undef, undef, undef, $mday, $month, $year); my $xsec = $sec + $SecOff + 60*$min + 3600*$hour; unless ($Options{no_range_check} or ($days > $Min{Day} or $days == $Min{Day} and $xsec >= $Min +{Sec}) and ($days < $Max{Day} or $days == $Max{Day} and $xsec <= $Max +{Sec})) { warn "Day too small - $days > $Min{Day}\n" if $days < $Min{Day +}; warn "Day too big - $days > $Max{Day}\n" if $days > $Max{Day}; warn "Sec too small - $days < $Min{Sec}\n" if $days < $Min{Sec +}; warn "Sec too big - $days > $Max{Sec}\n" if $days > $Max{Sec}; $year += 1900; croak "Cannot handle date ($sec, $min, $hour, $mday, $month, $year +)"; } no integer; $xsec + 86400 * $days; }

They seem to be different by a kilobyte or two. I noticed they both use CORE::gmtime() though.

-Paul


In reply to Re^5: Subtracting and Comparing Two Dates by jettero
in thread Subtracting and Comparing Two Dates by mindful07

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.