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

strftime uses wrong time zone for %Z #2475

Open
stollem opened this issue Aug 31, 2022 · 0 comments · May be fixed by #3203
Open

strftime uses wrong time zone for %Z #2475

stollem opened this issue Aug 31, 2022 · 0 comments · May be fixed by #3203

Comments

@stollem
Copy link

stollem commented Aug 31, 2022

Describe the bug
strftime (in jq) is documented to always format times in the UTC time zone. However, if %Z is part of the format, will be replaced with the systems local time zone, which is inconsistent with the rest of the time formatting, resulting in unexpected outputs

To Reproduce
$ echo '1661932759' | TZ="Europe/Zurich" jq '. | strflocaltime("%Y-%m-%dT%H:%M:%S_%Z"), strftime("%Y-%m-%dT%H:%M:%S_%Z")'
"2022-08-31T09:59:19_CET"
"2022-08-31T07:59:19_CET"

Note: the output is very misleading... the time passed in is NOT 07:59:18 CET

Expected behavior
$ echo '1661932759' | TZ="Europe/Zurich" jq '. | strflocaltime("%Y-%m-%dT%H:%M:%S_%Z"), strftime("%Y-%m-%dT%H:%M:%S_%Z")'
"2022-08-31T09:59:19_CET"
"2022-08-31T07:59:19_UTC"

Note: the second line correct shows that the printed time is in UTC

Environment (please complete the following information):

  • Linux Debian testing
  • jq-1.6 (Debian package version 1.6-2.1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants