diff --git a/src/datetime.js b/src/datetime.js index 1d9b2d92..1fac8b3f 100644 --- a/src/datetime.js +++ b/src/datetime.js @@ -994,6 +994,11 @@ const dateTime = (function () { } return offsetHours * 60 + offsetMinutes; }; + } else if (part.component === 'f') { + res.regex = '[0-9]+'; + res.parse = function(value) { + return parseFloat('0.' + value.substring(0, 3)) * 1000; + }; } else if (part.integerFormat) { res = generateRegex(part.integerFormat); } else { diff --git a/test/test-suite/groups/function-tomillis/parseDateTime.json b/test/test-suite/groups/function-tomillis/parseDateTime.json index b01e16f4..63b6e4ab 100644 --- a/test/test-suite/groups/function-tomillis/parseDateTime.json +++ b/test/test-suite/groups/function-tomillis/parseDateTime.json @@ -366,5 +366,13 @@ "expr": "$toMillis('2020-09-09 12:00:00 +0530', '[Y0001]-[M01]-[D01] [H01]:[m01]:[s01] [Z0001]') ~> $fromMillis() ", "data": {}, "result": "2020-09-09T06:30:00.000Z" + }, + { + "function": "#toMillis", + "category": "timezones", + "description": "should correctly parse fractional seconds of more than 3 digits, and truncate to millis", + "expr": "$toMillis('2026-04-08T19:05:04.01987', '[Y0001]-[M01]-[D01]T[H01]:[m01]:[s01].[f1]') ~> $fromMillis() ", + "data": {}, + "result": "2026-04-08T19:05:04.019Z" } ]