I don't think I understand.. can you please dumb it down even more?
I'd figured that UNIX time just counts actual seconds and that leap seconds and similar calendar shenanigans would be a problem of mapping epoch to the correct date, so that if normally epoch X maps to date D then both epoch X and X+1 map to date D.
Am i to understand that leap seconds "stretch" a epoch unit ? so that some epoch second "lasted longer".
Unix time does not count elapsed seconds in real time since 1970-01-01T00:00:00, this is a common misconception.
Unix time assumes a fixed number of seconds per day. 86400. If a leap second is inserted, either end of June or end of December, the day is 86401 seconds long.
There are different implementations for how your Unix time will behave 24 hours before to 24 hours after the leap second. A timestamp might just repeat during the leap second or the system changes the length of a second in a time range around the leap second introduction to make up the difference. This is called smearing.
A simple example is the elapsed time between these two timestamps:
Unix time differs by 20 seconds (assuming the system/library doesn't use smearing). But actually elapsed time is 21 seconds, since was the last added leap second. This timestamp cannot be represented by Unix time (again assuming no smearing, with smearing you could).> I'd figured that UNIX time just counts actual seconds
It doesn't. UNIX time is 1:1 with what your clock reads, you can convert between 2026-07-10 00:12:25 UTC and 1783642345 by simple math (note how the last digit is the same; but the leap second offset is 37s, that wouldn't align. The TAI timestamp for the same moment in time is 1783642382.)
> and that leap seconds and similar calendar shenanigans would be a problem of mapping epoch to the correct date, so that if normally epoch X maps to date D then both epoch X and X+1 map to date D.
It's the other way around, if you need to get the exact seconds between two UNIX timestamps (or calendar date/time), you need to check if there were any leap second changes between the two.
Counting actual seconds is TAI [https://en.wikipedia.org/wiki/International_Atomic_Time], that one is really just "number of Caesium hyperfine transitions since X", and now the mapping to a calendar date/time for display is a bit involved.
The seconds to calendar date conversion doesn't actually need to know about leap seconds. At the seconds representation level, the same number is repeated twice (or the smearing trategy happens).
So the times before and after leap second get converted the the same date regardless of whether you know about the leap second or not. Edge case is that once second occuring twice. You might have seen that 23:59:60 seconds timestamp somewhere.
I think for the stretch of time where a leap second is smeared, the epoch second would drift by a tiny fraction for each second or etc? So you'd have some chunk of UTC time where each second lasts something like 1.0005 epoch seconds, maybe? This would make converting from unix time to UTC need extra arbitrary handling for display, at least.
> I think for the stretch of time where a leap second is smeared, the epoch second would drift by a tiny fraction for each second or etc? So you'd have some chunk of UTC time where each second lasts something like 1.0005 epoch seconds, maybe?
Yes, 1.0000116s (or 0.9999884s), and to be clear it was never intended like that. It got started after a bunch of bugs in leap second handling caused issues & some people thought it would be better to just stretch/compress time for a period around leap seconds, for docs refer to e.g.: https://developers.google.com/time/smear
Personally speaking - it's a great way of just pushing the problem around, further complicating an already complex situation. 11.6µs is very measurable on a modern system.
> This would make converting from unix time to UTC need extra arbitrary handling for display, at least.
Except you need to know that leap smearing has been applied… which of course noone records. Most systems can't even signal it, much less store. If you need that level of precision, you better make sure none of your systems uses it or you're just screwed.
If you're relying on system time for subsecond precision, you're already screwed on every other day that doesn't have leap seconds.
> 11.6µs is very measurable on a modern system.
11.6µs is very measurable.
Clock skew of 11.6 PPM is much more subtle.