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

strflocaltime always outputs +0000 for %Z #2429

Open
poettig opened this issue May 8, 2022 · 2 comments
Open

strflocaltime always outputs +0000 for %Z #2429

poettig opened this issue May 8, 2022 · 2 comments

Comments

@poettig
Copy link

poettig commented May 8, 2022

Describe the bug
jq outputs wrong timezone information when using strflocaltime with the %Z formatter:

└─$ timedatectl
               Local time: So 2022-05-08 13:48:24 CEST
           Universal time: So 2022-05-08 11:48:24 UTC
                 RTC time: So 2022-05-08 11:48:24
                Time zone: Europe/Berlin (CEST, +0200)
System clock synchronized: yes
              NTP service: active
          RTC in local TZ: no

└─$ jq -rn 'now | strflocaltime("%Y-%m-%dT%H:%M:%S%z")' 
2022-05-08T13:48:33+0000

To Reproduce
TZ=Asia/Tokyo jq -rn 'now | strflocaltime("%Y-%m-%dT%H:%M:%S%z")'

└─$ TZ=Asia/Tokyo jq -rn 'now | strflocaltime("%Y-%m-%dT%H:%M:%S%z")' 
2022-05-08T20:51:59+0000

Expected behavior
Output should be like the date command:

└─$ TZ=Asia/Tokyo date +"%Y-%m-%dT%H:%M:%S%z"
2022-05-08T20:51:20+0900

Environment (please complete the following information):

  • OS and Version: Linux; Reproduced on Manjaro and Debian Bullseye
  • jq version: 1.6

Additional context
Might be related to #1912

@pkoppstein
Copy link
Contributor

For the record, strflocaltime behaves properly on a Mac, whether using jq 1.5 or 1.6:

TZ=Asia/Tokyo jq-1.6 -rn 'now | strflocaltime("%Y-%m-%dT%H:%M:%S%z")'
2022-05-09T04:30:43+0900

TZ=Asia/Tokyojq-1.5 -rn 'now | strflocaltime("%Y-%m-%dT%H:%M:%S%z")'
2022-05-09T04:32:25+0900

@trn1ty
Copy link

trn1ty commented Nov 4, 2022

$ uname 
NetBSD
$ jq -rn 'now | strflocaltime("%Y-%m-%dT%H:%M:%S%z")'
2022-11-04T19:29:13-0500
$ date '+%Y-%m-%dT%H:%M:%S%z'
2022-11-04T19:29:21-0400

This is on NetBSD 9.3, so the problem isn't isolated to GNU+Linux. It looks like there's something funky with the way jq figures out the time zone.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants