Skip to content

strflocaltime always outputs +0000 for %Z #2429

Closed
@poettig

Description

@poettig

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions