1 # Generate the 'leapseconds' file from 'leap-seconds.list'.
3 # This file is in the public domain.
6 print "# Allowance for leap seconds added to each time zone file."
8 print "# This file is in the public domain."
10 print "# This file is generated automatically from the data in the public-domain"
11 print "# leap-seconds.list file, which can be copied from"
12 print "# <ftp://ftp.nist.gov/pub/time/leap-seconds.list>"
13 print "# or <ftp://ftp.boulder.nist.gov/pub/time/leap-seconds.list>"
14 print "# or <ftp://tycho.usno.navy.mil/pub/ntp/leap-seconds.list>."
15 print "# For more about leap-seconds.list, please see"
16 print "# The NTP Timescale and Leap Seconds"
17 print "# <https://www.eecis.udel.edu/~mills/leap.html>."
19 print "# The International Earth Rotation and Reference Systems Service"
20 print "# periodically uses leap seconds to keep UTC to within 0.9 s of UT1"
21 print "# (which measures the true angular orientation of the earth in space)"
22 print "# and publishes leap second data in a copyrighted file"
23 print "# <https://hpiers.obspm.fr/iers/bul/bulc/Leap_Second.dat>."
24 print "# See: Levine J. Coordinated Universal Time and the leap second."
25 print "# URSI Radio Sci Bull. 2016;89(4):30-6. doi:10.23919/URSIRSB.2016.7909995"
26 print "# <https://ieeexplore.ieee.org/document/7909995>."
27 print "# There were no leap seconds before 1972, because the official mechanism"
28 print "# accounting for the discrepancy between atomic time and the earth's rotation"
29 print "# did not exist."
31 print "# The correction (+ or -) is made at the given time, so lines"
32 print "# will typically look like:"
33 print "# Leap YEAR MON DAY 23:59:60 + R/S"
35 print "# Leap YEAR MON DAY 23:59:59 - R/S"
37 print "# If the leap second is Rolling (R) the given time is local time (unused here)."
51 for (i in monthabbr
) {
52 monthnum
[monthabbr
[i
]] = i
56 monthlen
[4] = monthlen
[6] = monthlen
[9] = monthlen
[11] =
30
59 /^
#\tUpdated through/ || /^#\tFile expires on:/ {
60 last_lines = last_lines $
0 "\n"
63 /^
#[$][ \t]/ { updated = $2 }
64 /^
#[@][ \t]/ { expires = $2 }
75 if (old_TAI_minus_UTC
) {
76 if (old_TAI_minus_UTC
< TAI_minus_UTC
) {
81 m = monthnum
[month
] - 1
88 day
+= m ==
2 && year %
4 ==
0 && (year %
100 != 0 || year %
400 ==
0)
89 printf "Leap\t%s\t%s\t%s\t%s\tS\n", year
, month
, day
, sign
91 old_TAI_minus_UTC = TAI_minus_UTC
95 # The difference between the NTP and POSIX epochs is 70 years
96 # (including 17 leap days), each 24 hours of 60 minutes of 60
98 epoch_minus_NTP =
((1970 - 1900) * 365 + 17) * 24 * 60 * 60
101 print "# POSIX timestamps for the data in this file:"
102 printf "#updated %s\n", updated
- epoch_minus_NTP
103 printf "#expires %s\n", expires
- epoch_minus_NTP
104 printf "\n%s", last_lines