Wow, I hadn't thought about this code for 7 years!

Yes, there is some wild time weirdness out there and time zone offsets of 30 minutes for sure exist. If I remember right, there used to be a couple of places in the US that used a 30 minute offset for daylight savings time? I hadn't heard of a 15 minute time zone (or daylight time) difference before, but humans are capable of doing some amazingly stupid things! I guess that sort of confusion could be nice as an "excuse" if you are late to an appointment and the other side of the street is using local time 15 minutes ahead of you!

If I were re-doing this, I would add the minutes and seconds into the code, leaving out only the fractions of seconds which cannot be represented by epoch time. Epoch is basically a 32 bit int representing number of seconds since an arbitrary date that is related to the release of Unix. So the fractions of a second cannot be represented.

After 7 years, the algorithm remains sound: a) Convert the UTC date/time string into standard epoch seconds. Then, b) ask the local system what local time that epoch time means? I think the code is clear enough that I can leave that straight-forward extension to the reader...The epoch->local time standard function would handle this 30 minute stuff when given enough precision in the epoch time. So a 30 minute offset doesn't fundamentally change anything except the need for more precision.

My advice to always log data in UTC remains. Local time is a presentation thing for management.


In reply to Re^3: convert UTC time to system time zone's time with perl default method by Marshall
in thread convert UTC time to system time zone's time with perl default method by myuser

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.