1309577Sglebius# Generate the 'leapseconds' file from 'leap-seconds.list'. 2309577Sglebius 3309577Sglebius# This file is in the public domain. 4309577Sglebius 5309577SglebiusBEGIN { 6309577Sglebius print "# Allowance for leap seconds added to each time zone file." 7309577Sglebius print "" 8309577Sglebius print "# This file is in the public domain." 9309577Sglebius print "" 10309577Sglebius print "# This file is generated automatically from the data in the public-domain" 11325322Sgordon print "# leap-seconds.list file, which is copied from:" 12325322Sgordon print "# ftp://ftp.nist.gov/pub/time/leap-seconds.list" 13309577Sglebius print "# For more about leap-seconds.list, please see" 14309577Sglebius print "# The NTP Timescale and Leap Seconds" 15325322Sgordon print "# https://www.eecis.udel.edu/~mills/leap.html" 16309577Sglebius print "" 17309577Sglebius print "# The International Earth Rotation and Reference Systems Service" 18309577Sglebius print "# periodically uses leap seconds to keep UTC to within 0.9 s of UT1" 19309577Sglebius print "# (which measures the true angular orientation of the earth in space); see" 20325322Sgordon print "# Levine J. Coordinated Universal Time and the leap second." 21325322Sgordon print "# URSI Radio Sci Bull. 2016;89(4):30-6. doi:10.23919/URSIRSB.2016.7909995" 22325322Sgordon print "# http://ieeexplore.ieee.org/document/7909995/" 23309577Sglebius print "# There were no leap seconds before 1972, because the official mechanism" 24309577Sglebius print "# accounting for the discrepancy between atomic time and the earth's rotation" 25309577Sglebius print "# did not exist until the early 1970s." 26309577Sglebius print "" 27309577Sglebius print "# The correction (+ or -) is made at the given time, so lines" 28309577Sglebius print "# will typically look like:" 29309577Sglebius print "# Leap YEAR MON DAY 23:59:60 + R/S" 30309577Sglebius print "# or" 31309577Sglebius print "# Leap YEAR MON DAY 23:59:59 - R/S" 32309577Sglebius print "" 33309577Sglebius print "# If the leapsecond is Rolling (R) the given time is local time." 34309577Sglebius print "# If the leapsecond is Stationary (S) the given time is UTC." 35309577Sglebius print "" 36309577Sglebius print "# Leap YEAR MONTH DAY HH:MM:SS CORR R/S" 37309577Sglebius} 38309577Sglebius 39309577Sglebius/^ *$/ { next } 40309577Sglebius 41309577Sglebius/^#\tUpdated through/ || /^#\tFile expires on:/ { 42309577Sglebius last_lines = last_lines $0 "\n" 43309577Sglebius} 44309577Sglebius 45309577Sglebius/^#/ { next } 46309577Sglebius 47309577Sglebius{ 48309577Sglebius NTP_timestamp = $1 49309577Sglebius TAI_minus_UTC = $2 50309577Sglebius hash_mark = $3 51309577Sglebius one = $4 52309577Sglebius month = $5 53309577Sglebius year = $6 54309577Sglebius if (old_TAI_minus_UTC) { 55309577Sglebius if (old_TAI_minus_UTC < TAI_minus_UTC) { 56309577Sglebius sign = "23:59:60\t+" 57309577Sglebius } else { 58309577Sglebius sign = "23:59:59\t-" 59309577Sglebius } 60309577Sglebius if (month == "Jan") { 61309577Sglebius year--; 62309577Sglebius month = "Dec"; 63309577Sglebius day = 31 64309577Sglebius } else if (month == "Jul") { 65309577Sglebius month = "Jun"; 66309577Sglebius day = 30 67309577Sglebius } 68309577Sglebius printf "Leap\t%s\t%s\t%s\t%s\tS\n", year, month, day, sign 69309577Sglebius } 70309577Sglebius old_TAI_minus_UTC = TAI_minus_UTC 71309577Sglebius} 72309577Sglebius 73309577SglebiusEND { 74309577Sglebius printf "\n%s", last_lines 75309577Sglebius} 76