> Build your time library on (un)signed 64 bit integers representing the number of nanoseconds since the utc epoch.
You poor sweet summer child. Has no one told you about the leap seconds yet? Unix time is not the number of seconds since epoch. It deliberately excludes leap seconds, which happen unpredictably whenever scientists measure the Earth as having spun at a different enough speed for long enough.
Time is fucked on every level:
- Philosophical: What is time? We just don't know.
- Physical: Turns out there is no such thing as simultaneity, and time flows differently at different locations. Time may be discrete at the Planck level, but we don't really know yet.
- Cosmological: The Earth does not rotate at a constant speed, the Earth does not orbit the Sun at a fractional component of its rotation, and the Moon does not orbit at even ratio either.
- Historical: Humans have not used time or calendars consistently.
- Notational: Some time notations are ambiguous (e.g. during daylight savings transitions) and others are skipped.
- Regional: Different regions use subtly different clocks and calendars.
- Political: Different political actors choose to change time whenever they feel like it with little or no warning.
- Religious: Many religions come with their own system for timekeeping, and people don't like when outsiders impose other systems.