Live data from Hacker News

Falsehoods Programmers believe about Time

infiniteundo.com

41–50 of 222 posts

Re: Falsehoods Programmers believe about Time

#41
post #30
post #18

If you really want to stress test time handling code, try to get it to accept Feburary 29, 1900 and Feburary 29, 2000. The first doesn't exist but the second does. But really, with regards to time use whatever library came with you programming language.

That will stress it a bit, but to really torture it, see if it accepts 2012 June 30 23:59:60

Now that's just mean! ;)

Re: Falsehoods Programmers believe about Time

#43
post #9

About #7: doesn't a month always end in the same year it started?

The way you're thinking about it, yes -- but the passage of a month may take you from December the [mumbleth] to January the [mumbleth], which are in different years. For some strange reason, code in the wild doesn't always account for that, so the due date for an item may well be eleven months before the request was entered.

I like to call this kind of bug "New Year's Wake-up Call from Hell".

Re: Falsehoods Programmers believe about Time

#44
35. People will just assume all APIs and standard libs that deal with dates are sane

Adobe managed to build a pretty shitty Date object for ActionScript that takes days as a 1-indexed parameter, but months as 0-indexed. Hopefully ActionScript is not used in banking [1]

[1] http://help.adobe.com/en_US/FlashPlatform/reference/actionsc...

Re: Falsehoods Programmers believe about Time

#46

Earlier quoted context omitted.

36. Two timezones that differ will differ by an integer number of half hours. 37. Okay, quarter hours. 38. Okay, seconds, but it will be a consistent difference if we ignore DST.

39. If you create two date objects right beside each other, they'll represent the same time. (a fantastic Heisenbug generator) 40. You can wait for the clock to reach exactly HH:MM:SS by sampling once a second.

I'm not sure this counts as a constructive comment, but an interesting anecdote anyway - an early coding partner of mine once wrote a procedure he expected to run once exactly every second by continuously polling the time in a while/do_nothing loop until exactly one second had passed. It took some convincing to get him to accept that try as he might, it was very unlikely that "==" was what he wanted there.

The best part was that this was in Javascript (and obviously he was not using a timeout). The entire page would lock up while it waited for the second to elapse. He never even figured out the obvious usability concern because he was so confounded by the fact that the procedure wasn't getting called after a second had passed.

Ok, to be fair, it was a freshman year programming class - not an unexpected or even unusual mistake. But it gave me a chuckle just now remembering it.

Re: Falsehoods Programmers believe about Time

#50
post #36

Earlier quoted context omitted.

> September 1752 had 19 days: 1, 2, 14, 15, ..., 29, 30. In the British Empire, anyway.

From which many modern reckonings of time descend, including the one used by all modern computer systems.

Actually, almost no country outside the British Empire (and not even Scotland inside it) implemented the Gregorian reform at the same time. Britain was pretty late in doing so, too.

As for "all modern computer systems", Unix time is completely ignorant about anything except seconds.

Post reply on HN