Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Possible inconsistency with use of TZ to change zone output '%Z"



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


Messages sorted by: Reverse Date, Date, Thread, Author