The bug is easily fixable. Change:

sub _daygm { $_[3] + ($Cheat{pack("ss",@_[4,5])} ||= do { my $month = ($_[4] + 10) % 12; my $year = $_[5] + 1900 - $month/10; 365*$year + $year/4 - $year/100 + $year/400 + ($month*306 + 5)/10 +- $Epoc }); }

to

sub _daygm { $_[3] + ($Cheat{pack("ss",@_[4,5])} ||= do { my $month = ($_[4] + 10) % 12; my $year = $_[5] + 1900 + ($_[4] + 10) / 12 - 1; 365*$year + $year/4 - $year/100 + $year/400 + ($month*306 + 5)/10 +- $Epoc }); }

My test:

use integer; print("month was new new\n"); print("----- --- --- ---\n"); foreach (0..23) { my $month = ($_ + 10) % 12; printf("%-5d %-3d %-3d %-3d\n", $_, -$month/10, -$month/10 + $_/12, ($_+10)/12-1 ); }

outputs

month was new new ----- --- --- --- 0 -1 -1 -1 1 -1 -1 -1 2 0 0 0 3 0 0 0 4 0 0 0 5 0 0 0 6 0 0 0 7 0 0 0 8 0 0 0 9 0 0 0 10 0 0 0 11 0 0 0 12 -1 0 0 13 -1 0 0 14 0 1 1 15 0 1 1 16 0 1 1 17 0 1 1 18 0 1 1 19 0 1 1 20 0 1 1 21 0 1 1 22 0 1 1 23 0 1 1

I created a ticket.


In reply to Re: timelocal_nocheck: bug or wrongly understood by ikegami
in thread timelocal_nocheck: bug or wrongly understood by borisz

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.