[tz] tzselect from current local time
Paul Eggert
eggert at cs.ucla.edu
Tue Jan 17 02:38:34 UTC 2023
On 2023-01-09 23:14, Paul Eggert wrote:
>
>> my UI is based on time, as the system is most likely to have a
>> valid UTC time, so the user will first select the current wall-clock time
>> and then a location for that time.
>
> Nice idea.
As the sincerest form of flattery, I implemented something like that in
TZDB's tzselect program by installing the attached proposed patches.
This sort of implementation via the shell would have been pretty slow
decades ago, but with modern CPUs it should be fast enough for human users.
Here's a sample shell interaction using this new feature. Although not
as good as a GUI, I hope this helps inspire other uses of this idea. And
perhaps if we ever get around to implementing the simplified interface
for users who care only about timestamps from now on, tzselect can get
even simpler when exploiting this idea.
$ tzselect
Please identify a location so that time zone rules can be set correctly.
Please select a continent, ocean, "coord", "TZ", or "time".
1) Africa
2) Americas
3) Antarctica
4) Arctic Ocean
5) Asia
6) Atlantic Ocean
7) Australia
8) Europe
9) Indian Ocean
10) Pacific Ocean
11) coord - I want to use geographical coordinates.
12) TZ - I want to specify the timezone using the Posix TZ format.
13) time - I know local time already.
#? 13
What is the current date and 24-hour time?
1) Mon Jan 16 15:34 14) Tue Jan 17 02:34 27) Tue Jan 17 10:34
2) Mon Jan 16 16:34 15) Tue Jan 17 03:34 28) Tue Jan 17 11:19
3) Mon Jan 16 17:04 16) Tue Jan 17 04:34 29) Tue Jan 17 11:34
4) Mon Jan 16 17:34 17) Tue Jan 17 05:34 30) Tue Jan 17 12:04
5) Mon Jan 16 18:34 18) Tue Jan 17 06:04 31) Tue Jan 17 12:34
6) Mon Jan 16 19:34 19) Tue Jan 17 06:34 32) Tue Jan 17 13:04
7) Mon Jan 16 20:34 20) Tue Jan 17 07:04 33) Tue Jan 17 13:34
8) Mon Jan 16 21:34 21) Tue Jan 17 07:34 34) Tue Jan 17 14:34
9) Mon Jan 16 22:34 22) Tue Jan 17 08:04 35) Tue Jan 17 15:34
10) Mon Jan 16 23:04 23) Tue Jan 17 08:19 36) Tue Jan 17 16:19
11) Mon Jan 16 23:34 24) Tue Jan 17 08:34 37) Tue Jan 17 16:34
12) Tue Jan 17 00:34 25) Tue Jan 17 09:04
13) Tue Jan 17 01:34 26) Tue Jan 17 09:34
#? 1
Please select a country whose clocks agree with yours.
1) Niue 3) US minor outlying islands
2) Samoa (American)
#? 1
Based on the following information:
Mon Jan 16 15:34
Niue
TZ='Pacific/Niue' will be used.
Selected time is now: Mon Jan 16 15:34:25 -11 2023.
Universal Time is now: Tue Jan 17 02:34:25 UTC 2023.
Is the above information OK?
1) Yes
2) No
#? 1
You can make this change permanent for yourself by appending the line
TZ='Pacific/Niue'; export TZ
to the file '.profile' in your home directory; then log out and log in
again.
Here is that TZ value again, this time on standard output so that you
can use the ./tzselect command in shell scripts:
Pacific/Niue
$
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Refactor-country-list-awk-program.patch
Type: text/x-patch
Size: 3189 bytes
Desc: not available
URL: <http://mm.icann.org/pipermail/tz/attachments/20230116/3ccecd3c/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-Fix-tzselect-comment.patch
Type: text/x-patch
Size: 683 bytes
Desc: not available
URL: <http://mm.icann.org/pipermail/tz/attachments/20230116/3ccecd3c/attachment-0001.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0003-tzselect-can-now-use-current-time-to-help-choose.patch
Type: text/x-patch
Size: 8126 bytes
Desc: not available
URL: <http://mm.icann.org/pipermail/tz/attachments/20230116/3ccecd3c/attachment-0002.bin>
More information about the tz
mailing list