Skip to content

Allow more than 9 subsecond digits in ISO 8601 parsing - #1002

Open
mturac wants to merge 1 commit into
python-pendulum:masterfrom
mturac:fix/issue-935
Open

Allow more than 9 subsecond digits in ISO 8601 parsing#1002
mturac wants to merge 1 commit into
python-pendulum:masterfrom
mturac:fix/issue-935

Conversation

@mturac

@mturac mturac commented Sep 2, 2026

Copy link
Copy Markdown

Fixes #935.

the ISO 8601 regex for subsecond digits was \d{1,9}, so anything with more than 9 fractional digits raised a ParseError. some systems (.NET, certain database drivers, high-precision scientific instruments) regularly emit 10+ digits.

the fix just widens the capture group to \d+. the code that reads the match already does [:6] to truncate to microseconds, so no other changes needed.

>>> pendulum.parse('2024-09-30T12:20:33.1234567890')
# before: ParseError
# after:  DateTime(2024, 9, 30, 12, 20, 33, 123456, ...)

tested with timestamps from 1 to 13 fractional digits, with and without timezone offsets. existing tests unaffected.

The subsecond regex group only accepted 1-9 digits, so timestamps
with higher precision (e.g. from .NET or database drivers that emit
10+ fractional digits) raised a ParseError.

Widen the pattern to accept any number of digits. The processing
code already truncates to 6 digits for microseconds, so the change
is safe.
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 this pull request may close these issues.

parse fails with subsecond decimals with more than 9 digits

1 participant