leapseconds.awk revision 325159
1308265Sgjb# Generate the 'leapseconds' file from 'leap-seconds.list'. 2308265Sgjb 3308265Sgjb# This file is in the public domain. 4308265Sgjb 5308265SgjbBEGIN { 6308265Sgjb print "# Allowance for leap seconds added to each time zone file." 7308265Sgjb print "" 8308265Sgjb print "# This file is in the public domain." 9308265Sgjb print "" 10308265Sgjb print "# This file is generated automatically from the data in the public-domain" 11325159Sphilip print "# leap-seconds.list file, which is copied from:" 12325159Sphilip print "# ftp://ftp.nist.gov/pub/time/leap-seconds.list" 13308265Sgjb print "# For more about leap-seconds.list, please see" 14308265Sgjb print "# The NTP Timescale and Leap Seconds" 15325159Sphilip print "# https://www.eecis.udel.edu/~mills/leap.html" 16308265Sgjb print "" 17308265Sgjb print "# The International Earth Rotation and Reference Systems Service" 18308265Sgjb print "# periodically uses leap seconds to keep UTC to within 0.9 s of UT1" 19308265Sgjb print "# (which measures the true angular orientation of the earth in space); see" 20325159Sphilip print "# Levine J. Coordinated Universal Time and the leap second." 21325159Sphilip print "# URSI Radio Sci Bull. 2016;89(4):30-6. doi:10.23919/URSIRSB.2016.7909995" 22325159Sphilip print "# http://ieeexplore.ieee.org/document/7909995/" 23308265Sgjb print "# There were no leap seconds before 1972, because the official mechanism" 24308265Sgjb print "# accounting for the discrepancy between atomic time and the earth's rotation" 25308265Sgjb print "# did not exist until the early 1970s." 26308265Sgjb print "" 27308265Sgjb print "# The correction (+ or -) is made at the given time, so lines" 28308265Sgjb print "# will typically look like:" 29308265Sgjb print "# Leap YEAR MON DAY 23:59:60 + R/S" 30308265Sgjb print "# or" 31308265Sgjb print "# Leap YEAR MON DAY 23:59:59 - R/S" 32308265Sgjb print "" 33308265Sgjb print "# If the leapsecond is Rolling (R) the given time is local time." 34308265Sgjb print "# If the leapsecond is Stationary (S) the given time is UTC." 35308265Sgjb print "" 36308265Sgjb print "# Leap YEAR MONTH DAY HH:MM:SS CORR R/S" 37308265Sgjb} 38308265Sgjb 39308265Sgjb/^ *$/ { next } 40308265Sgjb 41308265Sgjb/^#\tUpdated through/ || /^#\tFile expires on:/ { 42308265Sgjb last_lines = last_lines $0 "\n" 43308265Sgjb} 44308265Sgjb 45308265Sgjb/^#/ { next } 46308265Sgjb 47308265Sgjb{ 48308265Sgjb NTP_timestamp = $1 49308265Sgjb TAI_minus_UTC = $2 50308265Sgjb hash_mark = $3 51308265Sgjb one = $4 52308265Sgjb month = $5 53308265Sgjb year = $6 54308265Sgjb if (old_TAI_minus_UTC) { 55308265Sgjb if (old_TAI_minus_UTC < TAI_minus_UTC) { 56308265Sgjb sign = "23:59:60\t+" 57308265Sgjb } else { 58308265Sgjb sign = "23:59:59\t-" 59308265Sgjb } 60308265Sgjb if (month == "Jan") { 61308265Sgjb year--; 62308265Sgjb month = "Dec"; 63308265Sgjb day = 31 64308265Sgjb } else if (month == "Jul") { 65308265Sgjb month = "Jun"; 66308265Sgjb day = 30 67308265Sgjb } 68308265Sgjb printf "Leap\t%s\t%s\t%s\t%s\tS\n", year, month, day, sign 69308265Sgjb } 70308265Sgjb old_TAI_minus_UTC = TAI_minus_UTC 71308265Sgjb} 72308265Sgjb 73308265SgjbEND { 74308265Sgjb printf "\n%s", last_lines 75308265Sgjb} 76