• Kaewberg (unregistered)

    When the only tool you have is an axe, all problems start looking like co-workers.

  • Yazeran (unregistered)

    Well at least give them credit for some relevant historical reference, after all it's almost 100 years since the end of WW1 :-)

  • LCrawford (unregistered)

    Add a database. Now you have two problems.

  • Smash (unregistered) in reply to LCrawford

    I know, I'll use regular expression then!

  • my name is missing (unregistered)

    When all you have is a hammer, you use it to whack people.

  • Jimmy Smitts (unregistered)

    One of the few times I have actually said the words "What the F--k" out loud when reading this site.

  • Jay Kreibich (unregistered)

    The extra amusing thing is that SQLite has no native time, date, timestamp, or duration data types. The core database engine has no concept of times or dates. All it has is a few functions to convert between different time/date formats, mostly as strings. While not exactly the same, these functions are modeled after the standard C functions.

  • Chronomium (unregistered)

    If you can match a date to a pretty important historical event, it's not "arbitrary" enough.

  • Andytech (unregistered)

    I love the fact they knew enough to be aware of the strftime() function in SQLite, but not enough to go looking for an equivalent in the C standard libraries..... like maybe strftime(), the C library function that the SQLite documentation specifically mentions and links to....

  • D-Coder (unregistered)

    After watching a cow-orker repeatedly finding the most complex solutions to problems, I came up with "When all you have is a three-headed hammer, everything looks like three nails."

  • P. E. Dant (unregistered)

    The Armistice was at 11:00, not 11:11.

  • Gizz (unregistered)

    The armistice was signed near Paris. So not Zulu/GMT/UTC. So that's wrong, too. :)

  • LongTimeLurker (unregistered)

    Should the title of the article be "Liteweight Date Handling"?

  • PenguinF (unregistered)

    "We may leak some memory if this happens" hahahahahaha

  • HK-47 (unregistered)

    I long for the days when learning curve for becoming a software engineer was steep, and when only the most devoted people could learn how to write code, not to mention that reading code was a required skill.

  • (nodebb) in reply to Chronomium

    Everyone knows that if you want to specify an arbitrary time you use Mon Jan 2 15:04:05 -0700 MST 2006.

  • FRack'd (unregistered) in reply to Gizz

    Not back then ... Paris was GMT until a few decades later

  • (nodebb) in reply to Gizz

    Except that in 1918, France was on GMT, not CET. That change didn't happen until World War II.

  • bills (unregistered)

    http://bit.ly/2FTOgMG

  • siciac (unregistered) in reply to HK-47

    I long for the days when learning curve for becoming a software engineer was steep, and when only the most devoted people could learn how to write code, not to mention that reading code was a required skill.

    We're still in those days, so long as we stipulate that "becoming a software engineer" and "writing code" exclude code academy grads and other face typists.

  • Long time reader (unregistered)

    While I make no claim to being the best programmer in the world I sometimes read articles on this site and think meh, this has given me serious what the fuck thoughts

  • inigo delgado (google) in reply to Watson

    I'm afraid of asking this but... why?

    I only want to be part of that 'everyone' you know... social acceptance... :D

    Why is that datetime so usual? what happend that day?

  • Rudolf Polzer (google) in reply to inigo delgado

    Nothing special - it's a date chosen so that the date representation uniquely specified the date format.

    See: https://golang.org/pkg/time/

    Of course one could pick different values for this - in particular different orderings as this date is quite clearly US-centric - but the general idea us quite nice:

    • Use the sequence 1, 2, 3, 4, 5, 6, 7 for the elements month, day, hour, minute, second, year, time zone. This identified the positions of the fields. (0 based sequence could have worked too but could introduce parsing difficulties as 00 also occurs inside year numbers).
    • Use a PM time so distinguishing x and x+12 allows detecting 24h vs 12h time formats.
    • Use a two digit year so distinguishing x and x+2000 allows detecting 4 vs. 2 digit years.

    Personally, as an European, I'd have used 2001-02-03T20:05:06+0700 instead - but the date the Go team picked works too.

Leave a comment on “Lightweight Date Handling”

Log In or post as a guest

Replying to comment #494251:

« Return to Article