Brooks Harris <brooks@edlmax.com> wrote:
While the Posix time specification is somewhat vague (and, as I understand it, *intentionally* vague to accommodate legacy systems) the NTP specification is more clear.
To a limited extent. NTP is all about distributing the current time so the exact meaning of historical timestamps is largely irrelevant. NTP has the same issue as POSIX time that it skips leapseconds: there is a fixed numerical offset between NTP and POSIX time, stated in RFC 5905 figure 4: | 1 Jan 1970 | 40,587 | 0 | 2,208,988,800 | First day UNIX | | 31 Dec 1999 | 51,543 | 0 | 3,155,587,200 | Last day 20th | | | | | | Century | $ TZ=UTC date -d @$((3155587200 - 2208988800)) +%FT%TZ 1999-12-31T00:00:00Z So, like POSIX time, you can't tell which UTC time corresponds to an NTP timestamp around a leapsecond without some extra information. The definition of POSIX time makes it clear that a positive leap second gets the same time_t value as the following second, but NTP does not specify how leapseconds are labelled to that level of detail. The NTP wire protocol has two leap second warning bits, but their values are not synchronized to the leap second, so they cannot be used to disambiguate the timestamp. Insted they relate to how the NTP daemon and the kernel clocks communicate state: the NTP leap second warning bits correspond to the ntp_adjtime() STA_INS and STA_DEL flags, but to disambiguoate timestamps you need the return values TIME_OOP or TIME_WAIT which are not present on the wire. An NTP server will continue returning the same leap warning flags through the leap second (while ntp_adjtime would return TIME_OOP or TIME_WAIT) until the next time it adjusts the clock and resets the leap state. https://www.freebsd.org/cgi/man.cgi?ntp_adjtime The upshot is that you can't use NTP as a good example of how to label timestamps. Tony. -- f.anthony.n.finch <dot@dotat.at> http://dotat.at/ St Davids Head to Great Orme Head, including St Georges Channel: Southwest 6 or 7, increasing gale 8 at times. Moderate or rough, but slight or moderate northeast of Anglesey. Occasional rain or drizzle. Moderate or good, occasionally poor.