[tz] [PROPOSED] Improve leapseconds support
Paul Eggert
eggert at cs.ucla.edu
Sat Oct 6 17:22:43 UTC 2018
(Inspired by a suggestion from Chris Woodbury.)
* NEWS, leapseconds.awk: Add support for leap seconds at the ends
of months other than June and December.
---
NEWS | 5 +++--
leapseconds.awk | 34 +++++++++++++++++++++++++---------
2 files changed, 28 insertions(+), 11 deletions(-)
diff --git a/NEWS b/NEWS
index e9f5366..9780cc8 100644
--- a/NEWS
+++ b/NEWS
@@ -86,8 +86,9 @@ Unreleased, experimental changes
transition (or for all time stamps if there are no transitions),
just as DST strings specifying DST have always done.
- leapseconds.awk now outputs "#updated" and "#expires" comments.
- (Inspired by a suggestion from Chris Woodbury.)
+ leapseconds.awk now outputs "#updated" and "#expires" comments,
+ and supports leap seconds at the ends of months other than June
+ and December. (Inspired by suggestions from Chris Woodbury.)
Changes to documentation
diff --git a/leapseconds.awk b/leapseconds.awk
index 6b069b3..ea0567c 100644
--- a/leapseconds.awk
+++ b/leapseconds.awk
@@ -35,9 +35,25 @@ BEGIN {
print "# Leap YEAR MON DAY 23:59:59 - R/S"
print ""
print "# If the leap second is Rolling (R) the given time is local time (unused here)."
- print "# If the leap second is Stationary (S) the given time is UTC."
- print ""
- print "# Leap YEAR MONTH DAY HH:MM:SS CORR R/S"
+
+ monthabbr[ 1] = "Jan"
+ monthabbr[ 2] = "Feb"
+ monthabbr[ 3] = "Mar"
+ monthabbr[ 4] = "Apr"
+ monthabbr[ 5] = "May"
+ monthabbr[ 6] = "Jun"
+ monthabbr[ 7] = "Jul"
+ monthabbr[ 8] = "Aug"
+ monthabbr[ 9] = "Sep"
+ monthabbr[10] = "Oct"
+ monthabbr[11] = "Nov"
+ monthabbr[12] = "Dec"
+ for (i in monthabbr) {
+ monthnum[monthabbr[i]] = i
+ monthlen[i] = 31
+ }
+ monthlen[2] = 28
+ monthlen[4] = monthlen[6] = monthlen[9] = monthlen[11] = 30
}
/^#\tUpdated through/ || /^#\tFile expires on:/ {
@@ -62,14 +78,14 @@ BEGIN {
} else {
sign = "23:59:59\t-"
}
- if (month == "Jan") {
+ m = monthnum[month] - 1
+ if (m == 0) {
year--;
- month = "Dec";
- day = 31
- } else if (month == "Jul") {
- month = "Jun";
- day = 30
+ m = 12
}
+ month = monthabbr[m]
+ day = monthlen[m]
+ day += m == 2 && year % 4 == 0 && (year % 100 != 0 || year % 400 == 0)
printf "Leap\t%s\t%s\t%s\t%s\tS\n", year, month, day, sign
}
old_TAI_minus_UTC = TAI_minus_UTC
--
2.17.1
More information about the tz
mailing list