Hacker News new | ask | show | jobs
by Kirby 6068 days ago
I've had more traumatic code errors due to times than I care to admit.

The bottom line: Learn from Unix. Store everything in epoch time (even if you're in Windows.) Do all your math in that. Showing local time is for display _only_. You won't ever regret it. (Well, hardly ever.)

3 comments

And don't store birthdays of anyone older (currently) than 39. I had a bug where I was enforcing epoch time for birthdates (Why? Long story) It worked when I (born in 1976) tested it, but it totally exploded when my more senior (in years) comrade tested it.

Embarrassing, that one.

Agree, but still be aware of leap seconds. Probably you want to choose to ignore them (as “unix time” does), but know what that means.
And retire before 2038.
And retire before 2038 if you still define time_t as a 32 bit signed integer.