diff options
Diffstat (limited to 'contrib/tzdata/leapseconds.awk')
-rw-r--r-- | contrib/tzdata/leapseconds.awk | 68 |
1 files changed, 49 insertions, 19 deletions
diff --git a/contrib/tzdata/leapseconds.awk b/contrib/tzdata/leapseconds.awk index 66eb64d..ea0567c 100644 --- a/contrib/tzdata/leapseconds.awk +++ b/contrib/tzdata/leapseconds.awk @@ -8,21 +8,25 @@ BEGIN { print "# This file is in the public domain." print "" print "# This file is generated automatically from the data in the public-domain" - print "# leap-seconds.list file, which is copied from:" - print "# ftp://ftp.nist.gov/pub/time/leap-seconds.list" + print "# leap-seconds.list file, which can be copied from" + print "# <ftp://ftp.nist.gov/pub/time/leap-seconds.list>" + print "# or <ftp://ftp.boulder.nist.gov/pub/time/leap-seconds.list>" + print "# or <ftp://tycho.usno.navy.mil/pub/ntp/leap-seconds.list>." print "# For more about leap-seconds.list, please see" print "# The NTP Timescale and Leap Seconds" - print "# https://www.eecis.udel.edu/~mills/leap.html" + print "# <https://www.eecis.udel.edu/~mills/leap.html>." print "" print "# The International Earth Rotation and Reference Systems Service" print "# periodically uses leap seconds to keep UTC to within 0.9 s of UT1" - print "# (which measures the true angular orientation of the earth in space); see" - print "# Levine J. Coordinated Universal Time and the leap second." + print "# (which measures the true angular orientation of the earth in space)" + print "# and publishes leap second data in a copyrighted file" + print "# <https://hpiers.obspm.fr/iers/bul/bulc/Leap_Second.dat>." + print "# See: Levine J. Coordinated Universal Time and the leap second." print "# URSI Radio Sci Bull. 2016;89(4):30-6. doi:10.23919/URSIRSB.2016.7909995" - print "# http://ieeexplore.ieee.org/document/7909995/" + print "# <https://ieeexplore.ieee.org/document/7909995>." print "# There were no leap seconds before 1972, because the official mechanism" print "# accounting for the discrepancy between atomic time and the earth's rotation" - print "# did not exist until the early 1970s." + print "# did not exist." print "" print "# The correction (+ or -) is made at the given time, so lines" print "# will typically look like:" @@ -30,18 +34,35 @@ BEGIN { print "# or" print "# Leap YEAR MON DAY 23:59:59 - R/S" print "" - print "# If the leapsecond is Rolling (R) the given time is local time." - print "# If the leapsecond is Stationary (S) the given time is UTC." - print "" - print "# Leap YEAR MONTH DAY HH:MM:SS CORR R/S" -} + print "# If the leap second is Rolling (R) the given time is local time (unused here)." -/^ *$/ { next } + monthabbr[ 1] = "Jan" + monthabbr[ 2] = "Feb" + monthabbr[ 3] = "Mar" + monthabbr[ 4] = "Apr" + monthabbr[ 5] = "May" + monthabbr[ 6] = "Jun" + monthabbr[ 7] = "Jul" + monthabbr[ 8] = "Aug" + monthabbr[ 9] = "Sep" + monthabbr[10] = "Oct" + monthabbr[11] = "Nov" + monthabbr[12] = "Dec" + for (i in monthabbr) { + monthnum[monthabbr[i]] = i + monthlen[i] = 31 + } + monthlen[2] = 28 + monthlen[4] = monthlen[6] = monthlen[9] = monthlen[11] = 30 +} /^#\tUpdated through/ || /^#\tFile expires on:/ { last_lines = last_lines $0 "\n" } +/^#[$][ \t]/ { updated = $2 } +/^#[@][ \t]/ { expires = $2 } + /^#/ { next } { @@ -57,19 +78,28 @@ BEGIN { } else { sign = "23:59:59\t-" } - if (month == "Jan") { + m = monthnum[month] - 1 + if (m == 0) { year--; - month = "Dec"; - day = 31 - } else if (month == "Jul") { - month = "Jun"; - day = 30 + m = 12 } + month = monthabbr[m] + day = monthlen[m] + day += m == 2 && year % 4 == 0 && (year % 100 != 0 || year % 400 == 0) printf "Leap\t%s\t%s\t%s\t%s\tS\n", year, month, day, sign } old_TAI_minus_UTC = TAI_minus_UTC } END { + # The difference between the NTP and POSIX epochs is 70 years + # (including 17 leap days), each 24 hours of 60 minutes of 60 + # seconds each. + epoch_minus_NTP = ((1970 - 1900) * 365 + 17) * 24 * 60 * 60 + + print "" + print "# POSIX timestamps for the data in this file:" + printf "#updated %s\n", updated - epoch_minus_NTP + printf "#expires %s\n", expires - epoch_minus_NTP printf "\n%s", last_lines } |