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

Week number is not taken into account during date creation in strptime #254

Closed
traut opened this issue May 16, 2024 · 5 comments
Closed

Comments

@traut
Copy link

traut commented May 16, 2024

It looks like gojq ignores the week number during strptime while JQ uses it for the output date:

$ jq -n '"2024, 20" | strptime("%Y, %W") | strftime("%Y-%m-%d")'
"2024-05-13"

$ gojq -n '"2024, 20" | strptime("%Y, %W") | strftime("%Y-%m-%d")'
"2024-01-01"

$ jq --version
jq-1.7

$ gojq --version
gojq 0.12.15 (rev: HEAD/go1.21.4)
@traut
Copy link
Author

traut commented May 16, 2024

moreover, it seems even incorrect week numbers are not caught:

$ jq -n '"2024, 99" | strptime("%Y, %W") | strftime("%Y-%m-%d")'
jq: error (at <unknown>): date "2024, 99" does not match format "%Y, %W"

$ gojq -n '"2024, 99" | strptime("%Y, %W") | strftime("%Y-%m-%d")'
"2024-01-01"

@traut
Copy link
Author

traut commented May 16, 2024

ah, this (from timefmt lib) explains the behavior -- the value for %W is parsed out but discarded 😞

@itchyny
Copy link
Owner

itchyny commented May 19, 2024

I have implemented parsing support for week numbers locally, will soon push to the repository.

@itchyny
Copy link
Owner

itchyny commented May 21, 2024

I have created a branch building with the latest timefmt-go with week number support, you can download the artifacts from here.

@itchyny
Copy link
Owner

itchyny commented Jun 1, 2024

Resolved by 1324e6e.

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

No branches or pull requests

2 participants