Hacker News new | ask | show | jobs
by chubot 4428 days ago
Haha, should be 86400, not 84600.
2 comments

I liked this one:

    SECONDS_PER_23_5_HOURS = 84600
That is a very common value to use when you want something to either occur a bit more than once a day, or time out in a bit less than a day.
And to keep the discussion interesting, also, 12 seconds is a pretty popular timespan to use when you want something longer than 10, but shorter than 15.
If there was an 84600 with no hinting variable names nearby, anyone reading would have trouble figuring out the author's intention. Any other number (say... 81234) would be unambiguous. In the words of Douglas Crockford, "All that you know about the code is that the programmer was incompetent."
I certainly have some code that adds 86399 to encompass the entirety of the day.

This is in languages I use with less robust date logic, of course.

Except it shouldn't, because when you have a leap second occur, suddenly you're off by a second.

A day is a day, it's not 86400 seconds.

Most operating systems and frameworks don't expose the concept of leap seconds to user code. For example, Unix time is the number of seconds since the epoch ignoring leap seconds, so a program that compares timestamps generated by time() would be correct in assuming that a day is 86400 units of time_t.