Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: populate timezone data when formatting time #3203

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

marcin-serwin
Copy link

The jv2tm function was zeroing fields of struct tm that were not specified by the standard. However, depending on the libc this produced incorrect timezone data when used together with formatting functions. This change tries to fill the timezone data using either mktime, timegm, or manually.

Fixes #2475 and #2429.

Example:

TZ=Asia/Tokyo jq -rn '1731627341 | strflocaltime("%F %T %z %Z"), strftime("%F %T %z %Z")'

Before:

2024-11-15 08:35:41 +0000 JST
2024-11-14 23:35:41 +0000 JST

After:

2024-11-15 08:35:41 +0900 JST
2024-11-14 23:35:41 +0000 GMT

The `jv2tm` function was zeroing fields of `struct tm` that were not
specified by the standard. However, depending on the libc this produced
incorrect timezone data when used together with formatting functions.
This change tries to fill the timezone data using either `mktime`,
`timegm`, or manually.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

strftime uses wrong time zone for %Z
1 participant