Some additional falsehoods programmers believe about time
Inspired by a conversation I had last night, and not all of these are covered by the more well-known lists.
Inspired by a conversation I had last night, and not all of these are covered by the more well-known lists.
- There are 365 days in a year.
- There are 365.25 days in a year.
- There are 365.24 days in a year.
- There are a fixed number of days in a year.
- Time zones never change.
- There are exactly 24 time zones.
- Okay, there are no more than 48 time zones.
- … Can’t be more than 100, right?
- Well at least time offsets never change.
- Fine, then, UTC never changes.
- … Okay, UTC will never change again.
- Daylight saving happens at the same time for everyone.
- Daylight saving happens at the same time for any given place.
- Daylight saving adjusts by one hour for everyone.
- All time zones are based on whole-hour offsets.
- … Okay, 30 minutes?
- … 15 minutes?
- Well at least we know that all time zones are based on the same offset every day.
- A timestamp means the same thing in retrospect as it does today.
- Any number that can be parsed as a timestamp is a timestamp.
- Adding more precision to a number parsed as a timestamp won’t hurt.
- General relativity doesn’t matter for timekeeping.
- …Special relativity doesn’t matter for timekeeping?
- There are exactly 86400 seconds in every day.
- There are exactly 86400 seconds in most days.
- All seconds are the same length.
- Two devices with the same sampling interval will record the same number of samples within the same time period.
- Two identical devices with the same sampling interval will record the same number of samples within the same time period.
- Two circuits within the same device will record the same number of samples within the same time period.
- All devices have a single global clock.
- All devices with multiple clocks will have those clocks remain in sync.
- All devices with multiple clocks will have those clocks move at a fixed interval relative to one another.
- The reported time on an RTC will always move forward.
- A single CPU with a single RTC will always report time that moves forward.
- A single CPU with a single RTC will always report time that moves forward if it isn’t synchronized to an external source such as NTP or GPS.
- If you synchronize your times via NTP you will never have to worry about clocks drifting.
- If you synchronize your devices via NTP you never have to worry about time moving backwards.
- Highly-precise time can be reported accurately using a CPU’s instruction counter.
- Any two times can be arbitrarily compared using the mathematical greater-than/less-than operator.
- A recorded timestamp that comes after a previous recorded timestamp will always compare as numerically greater.
- All HH:MM:SS-format time stamps go from 00:00:00 thru 23:59:59.
- Timestamps formatted in ISO-8601 can be sorted lexically.
- Timestamps formatted in ISO-8601 and kept within a single timezone can be sorted lexically.
- Timestamps formatted in ISO-8601 and with a single specified UTC offset can be sorted lexically.
- All timekeeping can be performed based on local time.
- All timekeeping can be performed based on UTC.
- All timekeeping can be performed based on storing as UTC and displaying in the local timezone.
- All timekeeping can be done reasonably with a single canonical representation.
- Any single event or item can be stored with a single canonical date.
- Okay, we can use a single date for “authored on” and another one for “last modified”
- It is easy to determine whether something happened in the past based solely on its timestamp
- The concept of “now” is consistent.
And some bonus things where people get confused about time zones in general:
- 2:20 PM PDT is two minutes after 2:18 PM EDT
- The time zone is always called PST even during daylight saving, and scheduling a call for 4:30 PM PST totally makes sense in the middle of June
Comments
Before commenting, please read the comment policy.
Avatars provided via Libravatar