Only the first call using a date in September 2004 is returned correctly. All other bad returns are for different dates within the same year and month.

I cannot reproduce your error, but I can understand what could be going on.

You see, Time::Local tries to approach the epoch time in a particular month by a first guess, estimating how far off it is, and then guessing again... until it finds a time in the desired month. From the start till the end of that month, at least for gmtime, it's just a matter of multiplying the number of days, hours, minutes, seconds since the start of the month, with the appropriate factors, and adding them up, and add them to the value found for the start of the month. For localtime there's a chance it's off by an hour, due to summertime (AKA daylight savings time).

Anyway, once it calculated one time in that month, it caches that result, so it doesn't have to calculate it again for the next date in the same month.

Now if the first calculation for this particular is correct, but the next are off, it's clear to me that the caching system doesn't work as it ought to. It appears to cache a wrong value.

What version of Time::Local do you have? I recall some older version trying to store some values in a byte, though the value it tried to store was too big to fit in a byte. I'm guessing something like this is what's happening in your case. Upgrading Time::Local to a recent version should, hopefully, fix it.


In reply to Re: time::local by bart
in thread time::local by Anonymous Monk

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.