1309574Sglebius# Generate the 'leapseconds' file from 'leap-seconds.list'. 2309574Sglebius 3309574Sglebius# This file is in the public domain. 4309574Sglebius 5309574SglebiusBEGIN { 6309574Sglebius print "# Allowance for leap seconds added to each time zone file." 7309574Sglebius print "" 8309574Sglebius print "# This file is in the public domain." 9309574Sglebius print "" 10309574Sglebius print "# This file is generated automatically from the data in the public-domain" 11309574Sglebius print "# leap-seconds.list file available from most NIST time servers." 12309574Sglebius print "# If the URL <ftp://time.nist.gov/pub/leap-seconds.list> does not work," 13309574Sglebius print "# you should be able to pick up leap-seconds.list from a secondary NIST server." 14309574Sglebius print "# See <http://tf.nist.gov/tf-cgi/servers.cgi> for a list of secondary servers." 15309574Sglebius print "# For more about leap-seconds.list, please see" 16309574Sglebius print "# The NTP Timescale and Leap Seconds" 17309574Sglebius print "# http://www.eecis.udel.edu/~mills/leap.html" 18309574Sglebius print "" 19309574Sglebius print "# The International Earth Rotation and Reference Systems Service" 20309574Sglebius print "# periodically uses leap seconds to keep UTC to within 0.9 s of UT1" 21309574Sglebius print "# (which measures the true angular orientation of the earth in space); see" 22309574Sglebius print "# Terry J Quinn, The BIPM and the accurate measure of time," 23309574Sglebius print "# Proc IEEE 79, 7 (July 1991), 894-905 <http://dx.doi.org/10.1109/5.84965>." 24309574Sglebius print "# There were no leap seconds before 1972, because the official mechanism" 25309574Sglebius print "# accounting for the discrepancy between atomic time and the earth's rotation" 26309574Sglebius print "# did not exist until the early 1970s." 27309574Sglebius print "" 28309574Sglebius print "# The correction (+ or -) is made at the given time, so lines" 29309574Sglebius print "# will typically look like:" 30309574Sglebius print "# Leap YEAR MON DAY 23:59:60 + R/S" 31309574Sglebius print "# or" 32309574Sglebius print "# Leap YEAR MON DAY 23:59:59 - R/S" 33309574Sglebius print "" 34309574Sglebius print "# If the leapsecond is Rolling (R) the given time is local time." 35309574Sglebius print "# If the leapsecond is Stationary (S) the given time is UTC." 36309574Sglebius print "" 37309574Sglebius print "# Leap YEAR MONTH DAY HH:MM:SS CORR R/S" 38309574Sglebius} 39309574Sglebius 40309574Sglebius/^ *$/ { next } 41309574Sglebius 42309574Sglebius/^#\tUpdated through/ || /^#\tFile expires on:/ { 43309574Sglebius last_lines = last_lines $0 "\n" 44309574Sglebius} 45309574Sglebius 46309574Sglebius/^#/ { next } 47309574Sglebius 48309574Sglebius{ 49309574Sglebius NTP_timestamp = $1 50309574Sglebius TAI_minus_UTC = $2 51309574Sglebius hash_mark = $3 52309574Sglebius one = $4 53309574Sglebius month = $5 54309574Sglebius year = $6 55309574Sglebius if (old_TAI_minus_UTC) { 56309574Sglebius if (old_TAI_minus_UTC < TAI_minus_UTC) { 57309574Sglebius sign = "23:59:60\t+" 58309574Sglebius } else { 59309574Sglebius sign = "23:59:59\t-" 60309574Sglebius } 61309574Sglebius if (month == "Jan") { 62309574Sglebius year--; 63309574Sglebius month = "Dec"; 64309574Sglebius day = 31 65309574Sglebius } else if (month == "Jul") { 66309574Sglebius month = "Jun"; 67309574Sglebius day = 30 68309574Sglebius } 69309574Sglebius printf "Leap\t%s\t%s\t%s\t%s\tS\n", year, month, day, sign 70309574Sglebius } 71309574Sglebius old_TAI_minus_UTC = TAI_minus_UTC 72309574Sglebius} 73309574Sglebius 74309574SglebiusEND { 75309574Sglebius printf "\n%s", last_lines 76309574Sglebius} 77