Hmm, the slowdown for generic date/time calculations doesn't really come from the algorithm itself, but from the idiosyncracies of humans. Timezones shift, date calculations get all kinds of weird updates, there is all the summer/winter time kerfuffle, leap seconds, etc.

To name one of my favourite examples, the algorithm you posted will most likely fail for Samoa dates because of 2011. In 2011, Samoa skipped the 30th of December entirely, it went directly from the 29th to the 31st. That's why date/time modules are a mess of spagetti code that does all kinds of (slow'ish) lookups in many different tables, and some expensive calculations.

With date and time calculations, it's usually more important to get them correct then to get them fast. Some timestamps might even be impossible to get correct precisely, namely those in the future. A politically motivated change to a timezone here, a drop of daylightsaving time there, an updated Bulletin C thrown in the mix and your predicted timestamp completely goes down the drain...

You might also watch Tom Scott's video "The problem with time & timezones".

PerlMonks XP is useless? Not anymore: XPD - Do more with your PerlMonks XP
Also check out my sisters artwork and my weekly webcomics

In reply to Re: A Very Fast 64–Bit Date Algorithm by cavac
in thread A Very Fast 64–Bit Date Algorithm by mldvx4

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.