I'm surprised there is not native function. Does anyone know why?
I'm surprised there is not native function. Does anyone know why?
Redshift, famously based off Postgres, chose to implement it
But I just got done writing a reference clock driver for the Chrony NTP server/client for a GPS module which outputs GPS time. But Chrony needs samples in UTC, so I did have to care about leap seconds to make that particular GPS source usable. And I had to add a way to update the leap seconds offset when a new leap second will be scheduled. Thankfully I had no need to convert differences between wildly different timestamps to sub-second precision.
Nobody really cares except for pedantic or historian reasons. You have to use a specialized library for such non-dumbed-down dates in programming languages, and sql is not an exception. Day is exactly 86400 seconds, with an hour correction when formatting (or parsing) under system-known DST.
Almost all systems use generic dates (at a day granularity), which are isotropic at all times, by ignoring these historical jumps. The only real/modern things are DST and leap seconds, the latter also often ignored for programmer’s sanity.
Python: https://stackoverflow.com/questions/39686553/what-does-pytho...
Js (also mentions most others): https://stackoverflow.com/questions/53019726/where-are-the-l...
C#: https://stackoverflow.com/questions/8760674/are-nets-datetim...
Leap seconds only have sense in let’s name it “real-event-time” systems, where common generic dates are unusable anyway. It’s a complete nonsense in regular programming and in sql. Regular systems are okay with being off with each other, and leap seconds are smeared across much bigger differences by ntp et al.
Don’t overthink software dates.