zsh-users
 help / color / mirror / code / Atom feed
* Possible inconsistency with use of TZ to change zone output '%Z"
@ 2022-01-07  0:39 Jim
  2022-01-07  0:58 ` Bart Schaefer
  0 siblings, 1 reply; 4+ messages in thread
From: Jim @ 2022-01-07  0:39 UTC (permalink / raw)
  To: zsh

[-- Attachment #1: Type: text/plain, Size: 1321 bytes --]

1) using parameter expansion flag '%'
2) zsh/stat module
3) zsh/datetime module - strftime

TZ=UTC in all cases

All methods in outputting a time string appear to use strftime. zsh/stat
doesn't say so in man page, but uses the same formatting.

TZ is not treated the same way in all three uses. Parameter expansion
and zstat need TZ to be exported to give the correct result. Whereas
strftime does not.

1) Using parameter expansion flag '%' to get current date/time
module zsh/datetime  loaded Yes  DT=${(%):-%D{%Y-%m-%d_%H:%M:%S.%N_%Z}}
TZ exported NOT  2022-01-06_17:08:34.957909030_CST
TZ exported Yes  2022-01-06_23:08:34.958007858_UTC

module zsh/datetime  loaded NOT  DT=${(%):-%D{%Y-%m-%d_%H:%M:%S.%N_%Z}
TZ exported NOT  2022-01-06_17:08:34.958192556_CST
TZ exported Yes  2022-01-06_23:08:34.958318194_UTC

2) Output from zstat:
TZ exported NOT  2021-07-25_13:53:11.000000000_CDT
TZ exported Yes  2021-07-25_18:53:11.000000000_UTC

3) Output from strftime:
TZ exported NOT  2021-07-25_18:53:11.000000000_UTC
TZ exported Yes  2021-07-25_18:53:11.000000000_UTC

Can anyone tell me why TZ needs to be exported for 1 and 2, but not 3?
Personally I prefer not to have to export TZ to get the desired result,
but that's just me. I don't know the reasoning with each.

Thank in advance for any info you can offer,

Jim

[-- Attachment #2: Type: text/html, Size: 2509 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-01-12 19:11 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-07  0:39 Possible inconsistency with use of TZ to change zone output '%Z" Jim
2022-01-07  0:58 ` Bart Schaefer
2022-01-08 15:32   ` Jim
2022-01-12 19:09     ` Bart Schaefer

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).