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

Converting unix timestamps in milliseconds occurs Assertion failed! #2123

Closed
WiVi71 opened this issue May 12, 2020 · 4 comments · Fixed by #2125
Closed

Converting unix timestamps in milliseconds occurs Assertion failed! #2123

WiVi71 opened this issue May 12, 2020 · 4 comments · Fixed by #2125

Comments

@WiVi71
Copy link

WiVi71 commented May 12, 2020

Edit

This bug was caused by too large a number. not strftime with "-R"
millierror

To Reproduce
ECHO {"published_at": 1461625253393} | jq ".published_at/1000 | strftime(\"%Y-%m-%d\")"
Converting unix timestamps in second works.
ECHO {"published_at": 1461625253393} | jq ".published_at | strftime(\"%Y-%m-%d\")"
But converting unix timestamps in milliseconds occurs unexpected type of error.

Expected behavior
jq should alart that the number is too big.

Environment (please complete the following information):

  • Jq-1.6-Windows10

-R_ER
Wrong jq command with -R options and strftime occurs "Assertion failed!"

To Reproduce
echo {"updateTime":1589179644052} | jq -R "fromjson? | .updateTime | strftime(\"%B %d %Y\")"

Expected behavior
Jq should print "compile error" or "syntax error" or something else.

@WiVi71 WiVi71 changed the title -R options and strftime occurs Assertion failed! Converting unix timestamps in milliseconds occurs Assertion failed! May 13, 2020
@itchyny
Copy link
Contributor

itchyny commented May 13, 2020

What's the result of jq -n "1461625253393 | gmtime" ?

@WiVi71
Copy link
Author

WiVi71 commented May 13, 2020

jq -n "1461625253393 | gmtime"
will print "jq: error (at ): errror converting number of seconds since epoch to datetime"

jq -n "1461625253393/1000 | gmtime"
will print

[
  2016,
  3,
  25,
  23,
  0,
  53.39299988746643,
  1,
  115
]

@itchyny
Copy link
Contributor

itchyny commented May 13, 2020

Thank you.

@itchyny
Copy link
Contributor

itchyny commented May 13, 2020

For a record, echo '{"updateTime":1589179644052000000}' | jq -R "fromjson? | .updateTime | strftime(\"%B %d %Y\")" is the reproducible command on macOS, and this command should print converting number of seconds since epoch to datetime. #2125 fixes the assertion failure but the command exits silently due to #1859.

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

Successfully merging a pull request may close this issue.

2 participants