Re: System time/timezone, was Re: Maximum size .bash_aliases file
On Sun 23 Jun 2024 at 08:41:51 (-0400), Greg Wooledge wrote:
> On Sat, Jun 22, 2024 at 23:25:43 -0500, David Wright wrote:
> > creation of Pacific/Kiritimati (+14:00), which became a press
> > story at the start of the new millennium.
> >
> > $ TZ=Pacific/Kiritamati date; TZ=Australia/Eucla date
> > Sun Jun 23 04:24:54 Pacific 2024
> > Sun Jun 23 13:09:54 +0845 2024
> > $
>
> Typo there; you misspelled "Kiritimati" in the command.
>
> hobbit:~$ TZ=Pacific/Kiritimati date; TZ=Australia/Eucla date
> Mon Jun 24 02:39:17 +14 2024
> Sun Jun 23 21:24:17 +0845 2024
Yes, I corrected it, but then carelessly pasted the incorrect lines.
> The fact that date(1) treats any misspelled or otherwise incorrect TZ
> variable as if it were UTC, but then goes on to write the mispelled
> time zone name in its *output*, as if it were actually being recognized,
> has tripped me up in the past. I really wish it would just throw an
> error... but it doesn't.
Yes, In the meantime, a function something like this might help:
$ type whattime
whattime is a function
whattime ()
{
[ -z "$1" ] && msgerr "Usage: ${FUNCNAME[0]} place
prints the present time at place (a filename in the zoneinfo lists).
For today's expiration (AoE), use the legacy name, GMT+12." && return 1;
local Where;
find /usr/share/zoneinfo/ \( -type f -o -type l \) | sed -E 's/^[^A-Z]+//;s/GMT\+12/AoE/' | grep -v [0-9] | sed -E 's/AoE/GMT\+12/' | sort -u | grep -i -e "^$1$" -e "/$1$" | while read Where; do
printf '%s ' "$Where";
TZ="$Where" date '+%Y-%m-%d %T %z %A';
done
}
$ for j in kiritimati eucla comodrivadavia samoa gmt+12 factory; do whattime "$j"; done
Pacific/Kiritimati 2024-06-24 13:54:22 +1400 Monday
Australia/Eucla 2024-06-24 08:39:22 +0845 Monday
America/Argentina/ComodRivadavia 2024-06-23 20:54:22 -0300 Sunday
Pacific/Samoa 2024-06-23 12:54:22 -1100 Sunday
US/Samoa 2024-06-23 12:54:22 -1100 Sunday
Etc/GMT+12 2024-06-23 11:54:22 -1200 Sunday
Factory 2024-06-23 23:54:22 -0000 Sunday
$
Cheers,
David.
Reply to:
- References:
- Re: System time/timezone, was Re: Maximum size .bash_aliases file
- From: Max Nikulin <manikulin@gmail.com>
- Re: System time/timezone, was Re: Maximum size .bash_aliases file
- From: Greg Wooledge <greg@wooledge.org>
- Re: System time/timezone, was Re: Maximum size .bash_aliases file
- From: David Wright <deblis@lionunicorn.co.uk>
- Re: System time/timezone, was Re: Maximum size .bash_aliases file
- Re: System time/timezone, was Re: Maximum size .bash_aliases file
- From: David Wright <deblis@lionunicorn.co.uk>
- Re: System time/timezone, was Re: Maximum size .bash_aliases file
- From: Stefan Monnier <monnier@iro.umontreal.ca>
- Re: System time/timezone, was Re: Maximum size .bash_aliases file
- From: Nicholas Geovanis <nickgeovanis@gmail.com>
- Re: System time/timezone, was Re: Maximum size .bash_aliases file
- From: Keith Bainbridge <keithrbau@gmail.com>
- Re: System time/timezone, was Re: Maximum size .bash_aliases file
- From: David Wright <deblis@lionunicorn.co.uk>
- Re: System time/timezone, was Re: Maximum size .bash_aliases file
- From: Greg Wooledge <greg@wooledge.org>