[tz] [PROPOSED] Support leap-seconds.list tombstone

Paul Eggert eggert at cs.ucla.edu
Fri Dec 23 01:58:54 UTC 2022


From: Paul Eggert <eggert at trombone>

This change looks forward to the possibility of leap seconds being
discontinued by 2035.  If and when that happens, the expiration
date on the leap-seconds.list file is likely to stop being
maintained, as there will be no need to issue new versions of
leap-seconds.list every six months.  Although the details have not
been decided, for now assume that the last edition of
leap-seconds.list will simply lack an expiration-date line.
* leapseconds.awk: If the input lacks an expiration line like
‘#@ 3896899200’, do not treat it as if ‘#@ 0’ were present, as
that would mean an expiration date of 1900-01-01.  Instead, do not
output an expiration date; just output a comment saying that there
is no expiration date.  Similarly for update dates and input
lacking lines like ’#$ 3676924800’.
---
 NEWS            |  3 +++
 leapseconds.awk | 50 ++++++++++++++++++++++++++++++-------------------
 2 files changed, 34 insertions(+), 19 deletions(-)

diff --git a/NEWS b/NEWS
index 9ac3367..5510823 100644
--- a/NEWS
+++ b/NEWS
@@ -42,6 +42,9 @@ Unreleased, experimental changes
     'restrict' keyword consistently with their documentation.
     This may allow future optimizations.
 
+    leapseconds.awk can now process a leap seconds file that never
+    expires; this might be useful if leap seconds are discontinued.
+
   Changes to commentary
 
     Note that leap seconds are planned to be discontinued by 2035.
diff --git a/leapseconds.awk b/leapseconds.awk
index b6c48bc..7d2556b 100644
--- a/leapseconds.awk
+++ b/leapseconds.awk
@@ -104,18 +104,23 @@ BEGIN {
 }
 
 END {
-    sstamp_to_ymdhMs(expires, ss_NTP)
-
     print ""
-    print "# UTC timestamp when this leap second list expires."
-    print "# Any additional leap seconds will come after this."
-    if (! EXPIRES_LINE) {
-      print "# This Expires line is commented out for now,"
-      print "# so that pre-2020a zic implementations do not reject this file."
+
+    if (expires) {
+      sstamp_to_ymdhMs(expires, ss_NTP)
+
+      print "# UTC timestamp when this leap second list expires."
+      print "# Any additional leap seconds will come after this."
+      if (! EXPIRES_LINE) {
+	print "# This Expires line is commented out for now,"
+	print "# so that pre-2020a zic implementations do not reject this file."
+      }
+      printf "%sExpires %.4d\t%s\t%.2d\t%.2d:%.2d:%.2d\n", \
+	EXPIRES_LINE ? "" : "#", \
+	ss_year, monthabbr[ss_month], ss_mday, ss_hour, ss_min, ss_sec
+    } else {
+      print "# (No Expires line, since the expires time is unknown.)"
     }
-    printf "%sExpires %.4d\t%s\t%.2d\t%.2d:%.2d:%.2d\n", \
-      EXPIRES_LINE ? "" : "#", \
-      ss_year, monthabbr[ss_month], ss_mday, ss_hour, ss_min, ss_sec
 
     # The difference between the NTP and POSIX epochs is 70 years
     # (including 17 leap days), each 24 hours of 60 minutes of 60
@@ -124,15 +129,22 @@ END {
 
     print ""
     print "# POSIX timestamps for the data in this file:"
-    sstamp_to_ymdhMs(updated, ss_NTP)
-    printf "#updated %d (%.4d-%.2d-%.2d %.2d:%.2d:%.2d UTC)\n", \
-      updated - epoch_minus_NTP, \
-      ss_year, ss_month, ss_mday, ss_hour, ss_min, ss_sec
-    sstamp_to_ymdhMs(expires, ss_NTP)
-    printf "#expires %d (%.4d-%.2d-%.2d %.2d:%.2d:%.2d UTC)\n", \
-      expires - epoch_minus_NTP, \
-      ss_year, ss_month, ss_mday, ss_hour, ss_min, ss_sec
-
+    if (updated) {
+      sstamp_to_ymdhMs(updated, ss_NTP)
+      printf "#updated %d (%.4d-%.2d-%.2d %.2d:%.2d:%.2d UTC)\n", \
+	updated - epoch_minus_NTP, \
+	ss_year, ss_month, ss_mday, ss_hour, ss_min, ss_sec
+    } else {
+      print "#(updated time unknown)"
+    }
+    if (expires) {
+      sstamp_to_ymdhMs(expires, ss_NTP)
+      printf "#expires %d (%.4d-%.2d-%.2d %.2d:%.2d:%.2d UTC)\n", \
+	expires - epoch_minus_NTP, \
+	ss_year, ss_month, ss_mday, ss_hour, ss_min, ss_sec
+    } else {
+      print "#(expires time unknown)"
+    }
     printf "\n%s", last_lines
 }
 
-- 
2.38.1



More information about the tz mailing list