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>."
28 print "# There were no leap seconds before 1972, because the official mechanism"
29 print "# accounting for the discrepancy between atomic time and the earth's rotation"
30 print "# did not exist. The first (\"1 Jan 1972\") data line in leap-seconds.list"
31 print "# does not denote a leap second; it denotes the start of the current definition"
34 print "# The correction (+ or -) is made at the given time, so lines"
35 print "# will typically look like:"
36 print "# Leap YEAR MON DAY 23:59:60 + R/S"
38 print "# Leap YEAR MON DAY 23:59:59 - R/S"
40 print "# If the leap second is Rolling (R) the given time is local time (unused here)."
54 for (i in monthabbr) {
55 monthnum[monthabbr[i]] = i
59 monthlen[4] = monthlen[6] = monthlen[9] = monthlen[11] = 30
62 /^#\tUpdated through/ || /^#\tFile expires on:/ {
63 last_lines = last_lines $0 "\n"
66 /^#[$][ \t]/ { updated = $2 }
67 /^#[@][ \t]/ { expires = $2 }
78 if (old_TAI_minus_UTC) {
79 if (old_TAI_minus_UTC < TAI_minus_UTC) {
84 m = monthnum[month] - 1
91 day += m == 2 && year % 4 == 0 && (year % 100 != 0 || year % 400 == 0)
92 printf "Leap\t%s\t%s\t%s\t%s\tS\n", year, month, day, sign
94 old_TAI_minus_UTC = TAI_minus_UTC
98 # The difference between the NTP and POSIX epochs is 70 years
99 # (including 17 leap days), each 24 hours of 60 minutes of 60
101 epoch_minus_NTP = ((1970 - 1900) * 365 + 17) * 24 * 60 * 60
104 print "# POSIX timestamps for the data in this file:"
105 printf "#updated %s\n", updated - epoch_minus_NTP
106 printf "#expires %s\n", expires - epoch_minus_NTP
107 printf "\n%s", last_lines