1309568Sglebius# Generate the 'leapseconds' file from 'leap-seconds.list'. 2309568Sglebius 3309568Sglebius# This file is in the public domain. 4309568Sglebius 5309568SglebiusBEGIN { 6309568Sglebius print "# Allowance for leap seconds added to each time zone file." 7309568Sglebius print "" 8309568Sglebius print "# This file is in the public domain." 9309568Sglebius print "" 10309568Sglebius print "# This file is generated automatically from the data in the public-domain" 11309568Sglebius print "# leap-seconds.list file available from most NIST time servers." 12309568Sglebius print "# If the URL <ftp://time.nist.gov/pub/leap-seconds.list> does not work," 13309568Sglebius print "# you should be able to pick up leap-seconds.list from a secondary NIST server." 14309568Sglebius print "# See <http://tf.nist.gov/tf-cgi/servers.cgi> for a list of secondary servers." 15309568Sglebius print "# For more about leap-seconds.list, please see" 16309568Sglebius print "# The NTP Timescale and Leap Seconds" 17309568Sglebius print "# http://www.eecis.udel.edu/~mills/leap.html" 18309568Sglebius print "" 19309568Sglebius print "# The International Earth Rotation and Reference Systems Service" 20309568Sglebius print "# periodically uses leap seconds to keep UTC to within 0.9 s of UT1" 21309568Sglebius print "# (which measures the true angular orientation of the earth in space); see" 22309568Sglebius print "# Terry J Quinn, The BIPM and the accurate measure of time," 23309568Sglebius print "# Proc IEEE 79, 7 (July 1991), 894-905 <http://dx.doi.org/10.1109/5.84965>." 24309568Sglebius print "# There were no leap seconds before 1972, because the official mechanism" 25309568Sglebius print "# accounting for the discrepancy between atomic time and the earth's rotation" 26309568Sglebius print "# did not exist until the early 1970s." 27309568Sglebius print "" 28309568Sglebius print "# The correction (+ or -) is made at the given time, so lines" 29309568Sglebius print "# will typically look like:" 30309568Sglebius print "# Leap YEAR MON DAY 23:59:60 + R/S" 31309568Sglebius print "# or" 32309568Sglebius print "# Leap YEAR MON DAY 23:59:59 - R/S" 33309568Sglebius print "" 34309568Sglebius print "# If the leapsecond is Rolling (R) the given time is local time." 35309568Sglebius print "# If the leapsecond is Stationary (S) the given time is UTC." 36309568Sglebius print "" 37309568Sglebius print "# Leap YEAR MONTH DAY HH:MM:SS CORR R/S" 38309568Sglebius} 39309568Sglebius 40309568Sglebius/^ *$/ { next } 41309568Sglebius 42309568Sglebius/^#\tUpdated through/ || /^#\tFile expires on:/ { 43309568Sglebius last_lines = last_lines $0 "\n" 44309568Sglebius} 45309568Sglebius 46309568Sglebius/^#/ { next } 47309568Sglebius 48309568Sglebius{ 49309568Sglebius NTP_timestamp = $1 50309568Sglebius TAI_minus_UTC = $2 51309568Sglebius hash_mark = $3 52309568Sglebius one = $4 53309568Sglebius month = $5 54309568Sglebius year = $6 55309568Sglebius if (old_TAI_minus_UTC) { 56309568Sglebius if (old_TAI_minus_UTC < TAI_minus_UTC) { 57309568Sglebius sign = "23:59:60\t+" 58309568Sglebius } else { 59309568Sglebius sign = "23:59:59\t-" 60309568Sglebius } 61309568Sglebius if (month == "Jan") { 62309568Sglebius year--; 63309568Sglebius month = "Dec"; 64309568Sglebius day = 31 65309568Sglebius } else if (month == "Jul") { 66309568Sglebius month = "Jun"; 67309568Sglebius day = 30 68309568Sglebius } 69309568Sglebius printf "Leap\t%s\t%s\t%s\t%s\tS\n", year, month, day, sign 70309568Sglebius } 71309568Sglebius old_TAI_minus_UTC = TAI_minus_UTC 72309568Sglebius} 73309568Sglebius 74309568SglebiusEND { 75309568Sglebius printf "\n%s", last_lines 76309568Sglebius} 77