From bc17b5300faba64adc17c09dd521fae8091d112e Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Tue, 17 Jan 2023 13:29:05 -0800
Subject: [PROPOSED] tzselect better signals wrong UTC clocks
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Problem reported by Robert Elz in:
https://mm.icann.org/pipermail/tz/2023-January/032533.html
* tzselect.ksh: Tell user the system’s UTC timestamp and ask them
to assume that it’s correct when selecting the local time.
This should warn users better if the UTC clock is wrong.
Also, use ‘TZ=UTC0 date’ rather than ‘date -u’ for consistency
with how ‘date’ is used elsewhere in this script.
---
 tzselect.ksh | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/tzselect.ksh b/tzselect.ksh
index 0e13cb1..41180ae 100644
--- a/tzselect.ksh
+++ b/tzselect.ksh
@@ -487,7 +487,8 @@ while
 		*)
 		case $continent in
 		time)
-		  old_minute=`date -u +%Y%m%d%H%M`
+		  minute_format='%a %b %d %H:%M'
+		  old_minute=`TZ=UTC0 date +"$minute_format"`
 		  for i in 1 2 3
 		  do
 		    time_table_command=`
@@ -495,13 +496,14 @@ while
 			  "$output_distances_or_times" <"$TZ_ZONE_TABLE"
 		    `
 		    time_table=`eval "$time_table_command"`
-		    new_minute=`date -u +%Y%m%d%H%M`
+		    new_minute=`TZ=UTC0 date +"$minute_format"`
 		    case $old_minute in
 		    "$new_minute") break;;
 		    esac
 		    old_minute=$new_minute
 		  done
-		  echo >&2 'What is the current date and 24-hour time?'
+		  echo >&2 "The system says Universal Time is $new_minute."
+		  echo >&2 "Assuming that's correct, what is the local time?"
 		  eval doselect `
 		    say "$time_table" |
 		    sort -k2n -k2,5 -k1n |
-- 
2.39.0

