Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/datetime.js
Original file line number Diff line number Diff line change
Expand Up @@ -982,6 +982,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) {
part.integerFormat.n = part.n;
res = generateRegex(part.integerFormat);
Expand Down Expand Up @@ -1296,7 +1301,7 @@ const dateTime = (function () {
}

// Regular expression to match an ISO 8601 formatted timestamp
var iso8601regex = new RegExp('^\\d{4}(-[01]\\d)*(-[0-3]\\d)*(T[0-2]\\d:[0-5]\\d:[0-5]\\d)*(\\.\\d+)?([+-][0-2]\\d:?[0-5]\\d|Z)?$');
var iso8601regex = new RegExp('^\\d{4}(-[01]\\d)?(-[0-3]\\d)?(T[0-2]\\d:[0-5]\\d:[0-5]\\d)?(\\.\\d+)?([+-][0-2]\\d:?[0-5]\\d|Z)?$');

/**
* Converts an ISO 8601 timestamp to milliseconds since the epoch
Expand Down
8 changes: 8 additions & 0 deletions test/test-suite/groups/function-tomillis/parseDateTime.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
]
Loading