From: Phil Pennock <zsh-workers+phil.pennock@spodhuis.org>
To: Clinton Bunch <cdbunch@zentaur.org>
Cc: zsh-users@zsh.org
Subject: Re: Timezones and print -P %D
Date: Thu, 12 Nov 2020 23:06:42 -0500 [thread overview]
Message-ID: <X64GUu7KPD6ZfH68@fullerene.field.pennock-tech.net> (raw)
In-Reply-To: <0e1487c3-589f-3b91-87e8-48fb964e633a@zentaur.org>
On 2020-11-12 at 13:38 -0600, Clinton Bunch wrote:
> Can someone explain what's going on here? I was under the impression that
> variable assignments on the command-line were exported to the environment
> and only effective for the life of the command.
>
> cdblinux[~]% unset TZ
> cdblinux[~]% print -P '%D{%Y-%m-%dT%H:%M%z}'
> 2020-11-12T13:32-0600
At this point, try something like:
ls -l /etc/localtime
sudo rm /etc/localtime
print -P '%D{%Y-%m-%dT%H:%M%z}'
sudo ln -sv $WhateverItWasBefore /etc/localtime
The key is that TZ is an override for "the time in the system timezone",
not for "the time in UTC". This is not Zsh but is probably somewhere in
POSIX.
> cdblinux[~]% TZ=UTC print -P '%D{%Y-%m-%dT%H:%M%z}'
> 2020-11-12T13:33-0600
This one confuses me. This, I would have expected to work without
needing to explicitly export TZ first. I think this might be a zsh bug.
> cdblinux[~]% export TZ
> cdblinux[~]% TZ=UTC print -P '%D{%Y-%m-%dT%H:%M%z}'
> 2020-11-12T19:33+0000
> cdblinux[~]% print -P '%D{%Y-%m-%dT%H:%M%z}'
> 2020-11-12T19:33+0000
The presence of $TZ in the environment overrides use of /etc/localtime;
if it's empty, that's UTC.
> cdblinux[~]% unset TZ
> cdblinux[~]% print -P '%D{%Y-%m-%dT%H:%M%z}'
> 2020-11-12T13:33-0600
And you're back to /etc/localtime
-Phil
prev parent reply other threads:[~2020-11-13 4:07 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-12 19:38 Clinton Bunch
2020-11-13 4:06 ` Phil Pennock [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=X64GUu7KPD6ZfH68@fullerene.field.pennock-tech.net \
--to=zsh-workers+phil.pennock@spodhuis.org \
--cc=cdbunch@zentaur.org \
--cc=zsh-users@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).