You could almost make a case for 'days', if you want to claim that a 24-hour duration should not be reported as 'one day' if it crossed a DST transition.

tye, thanks for this discussion. It follows closely along the lines of something we've been realising in the DateTime mailing list, and is important for anyone dealing with dates and times to realise: There are two kinds of math that deal with datetimes:

For the first sort of math, DateTime is not needed. Perhaps this is the only sort of date and time calculations you need, in which case, please continue to avoid using any date and time modules that talk about anything other than seconds. On the other hand, if you need the second sort of math, then you're going to need something a little more complex than just calling time().

But most of the time my preference would be to calculate durations in 'days' as simply 24-hour periods, no matter what the clock might read due to DST transitions or physical movement between timezones.

Well please stop it. A day is not 86400 seconds. Saying a process took 1 day because it took 86400 seconds is just wrong.

Lets imagine that some process takes exactly 86400 seconds, you tell your boss that it takes 1 day. He decides to run that process every day so that it completes at 9am, so therefore, according to you, it needs to start one day earlier at 9am. Now one day, due to daylight savings, this job does not complete until 10am, there are angry customers on the phone and the boss wants you in his office for a meeting.

But please explain how timezones change 60 seconds from being 1 minute or how timezones make a meaningful difference in something that would be reported in terms of 'months'.

I've updated the post you were replying to so that it now reads that you need something more complex than time(), time zones don't matter for a 60 second event, however you do need something that can handle a leap second (which could be your OS, but could be DateTime)


In reply to Re^4: Data: Dates, a DateTime replacement to perlfaq4 (TZ nit) by BigLug
in thread Data: Dates, a DateTime replacement to perlfaq4 by BigLug

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.