I am running a script converting a file containing specific times associated with data from one format to another. In the process I check that there is an equal amount of minutes between the times, since the file I convert from is more or less created manually and thus prone to errors. A typical time interval would be 20 minutes.

To check the update rate of the time I use timelocal to convert the date and time to seconds and then compare the previous value with the current value, checking that it is whatever timeinterval I expected.

This works fine for every date and time it has been used on apart from the infamous date and time 31.10.2004 01:00 compared with 31.10.2004 00:40. The number returned from this comparison is 4800 seconds == 80 minutes.

I checked the actual number output from timelocal and indeed, the number returned from 31.10.2004 01:00 is 1099180800 whereas the number returned from 31.10.2004 00:40 is 1099176000 leaving a difference of 4800. When feeding those numbers back into localtime it reveals the correct dates and time (same as the date and time that created them in timelocal).

Ideas anyone ? As I was typing this in it struck me that it is perhaps related to some kind of daylight saving time or some other kind of computer time issue like offset from UTC or other silliness.

I am running on IBM AIX v4.3, Perl version: 5.005_03

In reply to timelocal problems by olecs

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.