-
Notifications
You must be signed in to change notification settings - Fork 220
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
toMillis: Width formatting is not respected without a separator #546
Comments
JAMSUPREME
changed the title
Width formatting is not respected without a separator
toMillis: Width formatting is not respected without a separator
Oct 15, 2021
Closing. Fixed via #545 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Bug Summary
Width formatting doesn't appear to be respected without a separator.
Versions
JSONata
1.8.5
Node
v14.17.0
Detailed Information
Reference spec for width formatting: https://www.w3.org/TR/xpath-functions-31/#date-time-examples
At the moment, it appears the width formatting is not honored within
$toMillis
due to the way the regex is being generated. For an example input201802
, I should be able to specify a matcher[Y0001][M01]
which will result in a parsed value of2018/02/01
. At the moment, the library incorrectly grabs too many characters due to the+
regex so I end up with20180/02/01
Suggested Fix
I attempted a fix but you can let me know whether or not it's reasonable: #545
Work-around
I made a little helper function to grab the fixed-width portions of year/month/date via
substring
and then reformat the string prior to sending it totoMillis
:The library then functions as expected once the date string has been split via separators.
The text was updated successfully, but these errors were encountered: