Skip to content
New issue

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

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

Already on GitHub? # to your account

strptime/1 ignores timezone offset in datetime #111

Open
itchyny opened this issue Mar 12, 2022 · 2 comments
Open

strptime/1 ignores timezone offset in datetime #111

itchyny opened this issue Mar 12, 2022 · 2 comments
Labels
bug Something isn't working

Comments

@itchyny
Copy link
Collaborator

itchyny commented Mar 12, 2022

Currently xq can parse but ignores timezone offset in strptime/1. This is actually the same behavior of jq, but considered as a critical bug when we handle datetime with timezone offsets (ref: jqlang/jq#929, jqlang/jq#2195).

❯ jq 'strptime("%Y-%m-%dT%H:%M:%S%z") | todate' <<< '"2022-03-12T09:00:00+0900"'
"2022-03-12T09:00:00Z"

❯ xq 'strptime("%Y-%m-%dT%H:%M:%S%z") | todate' <<< '"2022-03-12T09:00:00+0900"'
"2022-03-12T09:00:00Z"

❯ gojq 'strptime("%Y-%m-%dT%H:%M:%S%z") | todate' <<< '"2022-03-12T09:00:00+0900"'
"2022-03-12T00:00:00Z"

❯ xq --version
xq 0.2.16-a1cdd48497de46711dc12042ccb1a4cb4bc7fcea
@MiSawa
Copy link
Owner

MiSawa commented Mar 12, 2022

I was aware of this issue and difference with gojq. Though I ignored it while I was replacing chrono with time, since it going to be complicated, especially when it comes to %Z, because of ambiguous timezone name and hardness of resolving timezone to offset....

But yeah, it'd be nice to support the feature. Though maybe we can only support %Z for UTC, GMT and perhaps the one (or more) from the locale.

@MiSawa MiSawa added the bug Something isn't working label Mar 12, 2022
@itchyny
Copy link
Collaborator Author

itchyny commented Mar 13, 2022

When this issue is resolved, it's useful if fromdateiso8601 supports timezone offsets. This is also reported to jq (jqlang/jq#1053).

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants