Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Timezones and print -P %D
- X-seq: zsh-users 26159
- From: Phil Pennock <zsh-workers+phil.pennock@xxxxxxxxxxxx>
- To: Clinton Bunch <cdbunch@xxxxxxxxxxx>
- Subject: Re: Timezones and print -P %D
- Date: Thu, 12 Nov 2020 23:06:42 -0500
- Archived-at: <https://zsh.org/users/26159>
- Archived-at: <http://www.zsh.org/sympa/arcsearch_id/zsh-users/2020-11/X64GUu7KPD6ZfH68%40fullerene.field.pennock-tech.net>
- Authentication-results: zsh.org; iprev=pass (mx.spodhuis.org) smtp.remote-ip=94.142.241.89; dkim=pass header.d=spodhuis.org header.s=d202011e2 header.a=ed25519-sha256; dkim=pass header.d=spodhuis.org header.s=d202011 header.a=rsa-sha256; dmarc=pass header.from=spodhuis.org; arc=none
- Cc: zsh-users@xxxxxxx
- Dkim-signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=spodhuis.org; s=d202011; h=OpenPGP:In-Reply-To:Content-Transfer-Encoding: Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:From: Reply-To:Subject:Date:To:Cc:Content-ID:Content-Description:OpenPGP: Organization; bh=u8iJbyG+9jT49vElQyNH72+kmbvX2/BwOUveNbrh+rM=; t=1605240407; x=1606450007; b=CxI+KLVze07zfV4htTHPZfFJMm7oWlEy+nBdGQuut5QBwBsJ1QIch4HAqQW3 /X2hcLus6MskdL2vpQwbdDP+CStfEHC2x6a42S8BGdcsDKWAvqZsBoz9uik81U0yk3jw1//i4Gsxi d+0OoBYyrAdZZb5oulx4/id9OVFh8xvopKzqL5uxc6UYoRHFwuJjtipdkmXHXucxonwsy7A8nWTxn lfIlMPa5M8LMnyS8I8afdBrNnPdapXU2oviI5wlmyvV1YVkr8zx2yv8GFYrdXnY/vO2dd8LXXRGBN 73sQ/WilIE226CtLBPwoi7JpSKyzxIOwGOOMiNiwUdyacgduTOw==;
- Dkim-signature: v=1; a=ed25519-sha256; q=dns/txt; c=relaxed/relaxed; d=spodhuis.org; s=d202011e2; h=OpenPGP:In-Reply-To:Content-Transfer-Encoding: Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:From: Reply-To:Subject:Date:To:Cc:Content-ID:Content-Description:OpenPGP: Organization; bh=u8iJbyG+9jT49vElQyNH72+kmbvX2/BwOUveNbrh+rM=; t=1605240407; x=1606450007; b=y6jHPhRr2WFBcMgxsTItpXZMIVWl89KKxRUL9xojGJEWaqLOGCUQFDvA3Als jS5Ua8Gi8gpwrWOA/QO4jYg6Dw==;
- In-reply-to: <0e1487c3-589f-3b91-87e8-48fb964e633a@zentaur.org>
- List-archive: <http://www.zsh.org/sympa/arc/zsh-users>
- List-help: <mailto:sympa@zsh.org?subject=help>
- List-id: <zsh-users.zsh.org>
- List-owner: <mailto:zsh-users-request@zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- List-subscribe: <mailto:sympa@zsh.org?subject=subscribe%20zsh-users>
- List-unsubscribe: <mailto:sympa@zsh.org?subject=unsubscribe%20zsh-users>
- Openpgp: url=https://www.security.spodhuis.org/PGP/keys/keys-2013rsa-2020cv25519.asc
- References: <0e1487c3-589f-3b91-87e8-48fb964e633a@zentaur.org>
- Sender: zsh-users-request@xxxxxxx
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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author