* 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
* Re: Possible inconsistency with use of TZ to change zone output '%Z"
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
0 siblings, 1 reply; 4+ messages in thread
From: Bart Schaefer @ 2022-01-07 0:58 UTC (permalink / raw)
To: linuxtechguy; +Cc: zsh
There's a lengthy discussion of this in the zsh-users thread with
subject "print builtin preceded by parameter assignment" from April
2019.
The upshot is that some system libraries only use the environment
strings when interpreting the time zone.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Possible inconsistency with use of TZ to change zone output '%Z"
2022-01-07 0:58 ` Bart Schaefer
@ 2022-01-08 15:32 ` Jim
2022-01-12 19:09 ` Bart Schaefer
0 siblings, 1 reply; 4+ messages in thread
From: Jim @ 2022-01-08 15:32 UTC (permalink / raw)
To: zsh
[-- Attachment #1: Type: text/plain, Size: 1438 bytes --]
Unfortunately my searches never found that mail thread. Sorry about that.
I'm sure the print builtin has nothing to do with the results I am getting.
1) DT=${(%):-%D{$Fmt}}
2) zstat -F $Fmt -A A +mtime $F
3) strftime -s DT $Fmt $ET
In each case the results were placed in a parameter then printed if and as
needed.
The thread left me somewhat confused, quite a bit to digest. Probably
because I'm
not a "developer" and know enough C to be a danger to myself and those
around
me. I understand that for a particular system the libraries may differ from
other systems, and once compiled, will "fix" the way it acts(environment
strings
or not). But if parameter expansion is using zsh's strftime shouldn't it
act the
same way as calling strftime directly. My results indicate that they don't.
It seems logical to me that they would. Admittedly I don't know the
internals, so
I'll accept the results and export TZ as needed.
Z-shell is still my all time favorite shell. Never cared for the de facto
linux default.
Sorry for the personal opinion.
Appreciated you taking the time to respond,
Jim
On Thu, Jan 6, 2022 at 6:58 PM Bart Schaefer <schaefer@brasslantern.com>
wrote:
> There's a lengthy discussion of this in the zsh-users thread with
> subject "print builtin preceded by parameter assignment" from April
> 2019.
>
> The upshot is that some system libraries only use the environment
> strings when interpreting the time zone.
>
[-- Attachment #2: Type: text/html, Size: 2088 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Possible inconsistency with use of TZ to change zone output '%Z"
2022-01-08 15:32 ` Jim
@ 2022-01-12 19:09 ` Bart Schaefer
0 siblings, 0 replies; 4+ messages in thread
From: Bart Schaefer @ 2022-01-12 19:09 UTC (permalink / raw)
To: linuxtechguy; +Cc: zsh
On Sat, Jan 8, 2022 at 7:33 AM Jim <linux.tech.guy@gmail.com> wrote:
>
> Unfortunately my searches never found that mail thread. Sorry about that.
> I'm sure the print builtin has nothing to do with the results I am getting.
I didn't mean to imply that you should have found that thread on your
own, sorry. The significant bit is that there is some discussion of
possible patches in that thread.
> But if parameter expansion is using zsh's strftime shouldn't it act the
> same way as calling strftime directly.
The %-replacements for zsh's strftime do not map 1-to-1 onto every
underlying strftime implementation, so it's not a direct pass-through.
However --
> 1) DT=${(%):-%D{$Fmt}}
> 2) zstat -F $Fmt -A A +mtime $F
> 3) strftime -s DT $Fmt $ET
-- the patch discussion from the other thread comes down to: In the
third case, the strftime builtin has an execution context in which it
is able to implicitly create a temporary export of TZ and then delete
it again before returning, so it does that (this was a change
implemented some time after the datetime module was first created).
In the first case there is no such context so a solution is messy, and
in the second (zstat) case the equivalent export has simply never been
implemented even though it would be possible to do so.
^ 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).