Well, hold on there a second, tye, that code is demonstration code, taken, as a matter of fact, from the DateTime docs, and only intended to show whether a library is broken or not.

You're quite right that it's unlikely you'd pass a value of 60 for seconds as part of a time string. (However, you might be given it as part of one, if you are reading UTC.)

The rather obvious way you would get bitten is when your program checks to see whether the next second after the current second is a new day. If your date handling code isn't up to, um, date, your program will tell you that it's January 1, 2017, one second before it really is, because it doesn't know to wait a sec.

$ perl -MDateTime -E ' say $DateTime::VERSION; say DateTime->from_epoch( epoch => 1483228800 )->datetime; say DateTime->from_epoch( epoch => 1483228799 )->add( seconds => 1 )-> +day; ' 1.33 2017-01-01T00:00:00 1
$ perl -MDateTime -E ' say $DateTime::VERSION; say DateTime->from_epoch( epoch => 1483228800 )->datetime; say DateTime->from_epoch( epoch => 1483228799 )->add( seconds => 1 )-> +day; ' 1.39 2017-01-01T00:00:00 31

Hope this helps!


The way forward always starts with a minimal test.

In reply to Re^2: Leap second coming up. Check your date handling code (reality) by 1nickt
in thread Leap second coming up. Check your date handling code by 1nickt

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.