Merge branch 'master' of git://repo.or.cz/unleashed into uadmin
[unleashed.git] / contrib / tzdata / leapseconds.awk
blob66eb64d3dcabda96399537a1ea04d651300a8915
1 # Generate the 'leapseconds' file from 'leap-seconds.list'.
3 # This file is in the public domain.
5 BEGIN {
6 print "# Allowance for leap seconds added to each time zone file."
7 print ""
8 print "# This file is in the public domain."
9 print ""
10 print "# This file is generated automatically from the data in the public-domain"
11 print "# leap-seconds.list file, which is copied from:"
12 print "# ftp://ftp.nist.gov/pub/time/leap-seconds.list"
13 print "# For more about leap-seconds.list, please see"
14 print "# The NTP Timescale and Leap Seconds"
15 print "# https://www.eecis.udel.edu/~mills/leap.html"
16 print ""
17 print "# The International Earth Rotation and Reference Systems Service"
18 print "# periodically uses leap seconds to keep UTC to within 0.9 s of UT1"
19 print "# (which measures the true angular orientation of the earth in space); see"
20 print "# Levine J. Coordinated Universal Time and the leap second."
21 print "# URSI Radio Sci Bull. 2016;89(4):30-6. doi:10.23919/URSIRSB.2016.7909995"
22 print "# http://ieeexplore.ieee.org/document/7909995/"
23 print "# There were no leap seconds before 1972, because the official mechanism"
24 print "# accounting for the discrepancy between atomic time and the earth's rotation"
25 print "# did not exist until the early 1970s."
26 print ""
27 print "# The correction (+ or -) is made at the given time, so lines"
28 print "# will typically look like:"
29 print "# Leap YEAR MON DAY 23:59:60 + R/S"
30 print "# or"
31 print "# Leap YEAR MON DAY 23:59:59 - R/S"
32 print ""
33 print "# If the leapsecond is Rolling (R) the given time is local time."
34 print "# If the leapsecond is Stationary (S) the given time is UTC."
35 print ""
36 print "# Leap YEAR MONTH DAY HH:MM:SS CORR R/S"
39 /^ *$/ { next }
41 /^#\tUpdated through/ || /^#\tFile expires on:/ {
42 last_lines = last_lines $0 "\n"
45 /^#/ { next }
48 NTP_timestamp = $1
49 TAI_minus_UTC = $2
50 hash_mark = $3
51 one = $4
52 month = $5
53 year = $6
54 if (old_TAI_minus_UTC) {
55 if (old_TAI_minus_UTC < TAI_minus_UTC) {
56 sign = "23:59:60\t+"
57 } else {
58 sign = "23:59:59\t-"
60 if (month == "Jan") {
61 year--;
62 month = "Dec";
63 day = 31
64 } else if (month == "Jul") {
65 month = "Jun";
66 day = 30
68 printf "Leap\t%s\t%s\t%s\t%s\tS\n", year, month, day, sign
70 old_TAI_minus_UTC = TAI_minus_UTC
73 END {
74 printf "\n%s", last_lines