Computer Time Scales
Contents
POSIX time (UNIX time)
Microsoft Windows file time (W32Time service) Microsoft .NET Framework DateTime Structure Microsoft Excel Serial Day Number Java NTP: Network Time Protocol PTP: Precision Time Protocol Other |
POSIX time (UNIX time)
- Unix operating system development began at Bell Labs, 1969 by Dennis Ritchie and Ken Thompson with first PDP-11 version becoming operational Feb 1971
- Internal dates and times kept in UTC
- Epoch defined as 00:00 UTC Jan 1, 1970 in Greg Calendar (JD 2440587.5)
- Chosen because many machines Unix initially deployed on couldn’t support arithmetic on integers longer than 32 bits without costly multiple-precision computation
- Time stored as 32 bit signed integer
- Unix time=0 at Unix epoch, but UTC didn’t exist until 1972
- If time kept in 32-bit signed quantity, on 3:14:08 UTC Tuesday Jan 19, 2038, it will go negative = chaos
- Largest value: 7FFFFFFF16 or 2,147,483,647 seconds
- Negative value corresponds to: 20:45:52 Friday 13, December 1901 UTC
- Unix Millennium Bug
- If time kept in 32-bit unsigned quantity, on 6:28:15 UTC Sunday Jan 7, 2106, it will go negative = chaos
- Largest value: FFFFFFFF16 or 4,294,967,295 seconds
- Negative value corresponds to: 00:00:00 Thursday 1 January 1970 UTC
- not all POSIX seconds have the same length and definition of the epoch is also fuzzy
- POSIX standard is self-inconsistent
- Attempts to address both mean solar seconds and atomic seconds, but can’t address leap seconds meaningfully
- 01:46:40 UTC on Sunday, 9 September 2001 was the Unix billennium (Unix time number 1,000,000,000), billenium is a portmanteau of billion and millennium
- At 23:31:30 UTC on 13 February 2009, the decimal representation of Unix time reached 1,234,567,890 seconds (like the number row on a keyboard)
- Wednesday, 26 January 2011 was the 15,000th day of Unix time
- 16:53:20 UTC on Tuesday, 13 May 2014, the Unix time value 1,400,000,000 seconds
- 06:28:16 UTC on Thursday, 7 Feb 2036, Network Time Protocol will loop over to the next epoch, as the 32-bit time stamp value used in NTP will overflow
- Unix Millennium Bug
- Unix Millennium Bug for 32-bit unsigned integers
- 15:30:08 UTC on Sunday, 4 December 292,277,026,596 64-bit versions of the Unix time stamp would cease to work, as it will overflow the largest value that can be held in a signed 64-bit number
Microsoft Windows file time (W32Time service)
- “the number of 100-nanosecond intervals that have elapsed since 12:00 A.M. January 1, 1601 Coordinated Universal Time (UTC)”
- year 1601 is prior to development of reasonably accurate escapement clocks, telescope, establishment of Royal Greenwich Observatory
- nothing could be called UTC prior to 1960 since UTC has been an atomically regulated time scale
Microsoft .NET Framework DateTime Structure
- "represents dates and times with values ranging from 12:00:00 midnight, January 1, 0001 Anno Domini (Common Era)" using "100-nanosecond units called ticks, and a particular date is the number of ticks since 12:00 midnight, January 1, 0001 A.D. (C.E.) in the Gregorian Calendar calendar"
- even worse than W32Time service
Microsoft Excel Serial Day Number
PC
Mac
- Dates and times defined as “serial numbers” with Midnight Jan 1, 1900 = day 1.0
- No time zones, NOW() function returns whatever computer clock set to
- “60” returns “Feb 29, 1900” (years divisible by 400 are leap years)
- All Excel day numbers following Feb 28, 1900 1 day greater than reality (error left in place)
- PC Excel day numbers valid between 1 and 2958465 (Jan 1, 1900-Dec 31, 9999)
- 0 deemed Jan 0, 1900
- Negative days and Y10K not handled at all
- Old versions of Excel did date arithmetic using 16 bit quantities and didn’t support day numbers greater than 65380 (Dec 31, 2078)
Mac
- Completely different from PC Excel since it is based on MacOS native time which counts days elapsed since January 1, 1904
- Numbered from 0 instead of 1: midnight January 1, 1904 has serial value 0.0
- Avoided counting 1900 as leap year by starting from 1904
- Mac Excel day numbers valid between 0 (Jan 1, 1904) and 2957003 (Dec 31, 9999)
- (same reason as PC Excel)
Java
Older Systems
Java.util.Date
Newer Systems
Java Date Time API/java.time (Java SE 8)
Java.util.Date
- Year counted from 1900, months, hours, minutes, and seconds start at 0 and days start at 1 (seconds go up to 61 for up to 2 leap seconds) (same as NTP)
- Has millisecond precision
- Non-intuitive scheme led to Joda-Time becoming popular
- allows for formatting (date -> text), parsing (text -> date), and normalization
Newer Systems
Java Date Time API/java.time (Java SE 8)
- free of concurrency issues found in previous systems which aren’t thread-safe
NTP: Network Time Protocol
- created 1980s
- able to keep computers all around the Internet synced to better than 50 ms
- usually better than 10 ms
- best case for distributed public network ~0.5 ms
- ~1 ms for limited private network under “ideal conditions”
- NTP timescale exchanged via unsigned 64-but fixed point integer where upper 32 bits represent integer seconds and lower 32 bits represent fractions of seconds to resolution of around 200 ps
- Current NTP era origin: 1900-01-01 00:00:00 UT
- Will wrap around in 2036
- Ignores leap seconds
PTP: Precision Time Protocol
- Defined in IEEE 1588-2002 standard (IEEE-SA à Institute of Electrical and Electronics Engineers Standards Association)
- Revised in IEEE 1588-2008
- Designed for sub-nanosecond timing, 10-11 frequency stability
- Master/slave timing
- Multiple boundary clocks