Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

How is handling a leap second any different from dealing with Daylight Savings Time, when a whole hour can skip or repeat itself? Wouldn't you just use the same logic?

Or is it the fact that servers tend to ignore DST, being set to GMT and using timezone+DST only for datetime rendering/parsing, like Unix timstamps? While leap seconds actually affect the clock itself?



Yep, it's the latter. Leap seconds actually affect time_t values, whereas daylight savings does not.

I think it's simpler to think of time_t (or "unix time") as independent of any time zone. It's the number of seconds since an arbitrary "epoch" that happened simultaneously everywhere in the world. It so happens that the epoch happened at midnight GMT.

Of course it's not literally the number of seconds since the epoch because of leap seconds.


It is literally the number of seconds because of leap seconds :)


Huh? When a leap second is added, a day has 86401 seconds, but time_t says it has only 86400. So the true number of seconds since the epoch drifts from time_t every time a leap second is added.


servers tend to ignore DST, being set to GMT ... While leap seconds actually affect the clock itself?

Yes.




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: