You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 input 201802, I should be able to specify a matcher [Y0001][M01] which will result in a parsed value of 2018/02/01. At the moment, the library incorrectly grabs too many characters due to the + regex so I end up with 20180/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 to toMillis:
JAMSUPREME
changed the title
Width formatting is not respected without a separator
toMillis: Width formatting is not respected without a separator
Oct 15, 2021
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: