Title: `parse` fails with subsecond decimals with more than 9 digits · Issue #935 · python-pendulum/pendulum · GitHub
Open Graph Title: `parse` fails with subsecond decimals with more than 9 digits · Issue #935 · python-pendulum/pendulum
X Title: `parse` fails with subsecond decimals with more than 9 digits · Issue #935 · python-pendulum/pendulum
Description: Python datetimes made easy. Contribute to python-pendulum/pendulum development by creating an account on GitHub.
Open Graph Description: Python datetimes made easy. Contribute to python-pendulum/pendulum development by creating an account on GitHub.
X Description: Python datetimes made easy. Contribute to python-pendulum/pendulum development by creating an account on GitHub.
Opengraph URL: https://github.com/python-pendulum/pendulum
X: @github
Domain: github.com
IPv4 address: 140.82.113.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`parse` fails with subsecond decimals with more than 9 digits","articleBody":"- [x] I am on the [latest](https://github.com/sdispater/pendulum/releases/latest) Pendulum version.\n- [x] I have searched the [issues](https://github.com/sdispater/pendulum/issues) of this repo and believe that this is not a duplicate.\n\n- **OS version and name**: Win10\n- **Pendulum version**: 3.1.0\n\n## Issue\n`pendulum.parse()` trhows ParseError when parsing an ISO8601 formatted date with subsecond decimals with more than 9 digits, independent on whether time offset is present or not.\n\nFor instance, the following parse attempt work (truncating decimals to microsecond resolution):\n\n````python\n>>> pendulum.parse(\"2001-01-01T12:34:56.123456789Z\")\nDateTime(2001, 1, 1, 12, 34, 56, 123456, tzinfo=Timezone('UTC'))\n````\n\nbut the same with an extra digit (even if it's 0) fail:\n\n```python\n>>> pendulum.parse(\"2001-01-01T12:34:56.1234567890Z\")\nTraceback (most recent call last):\n File \"\u003cpython-input-1>\", line 1, in \u003cmodule>\n parse(\"2001-01-01T12:34:56.1234567890\")\n ~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \".venv\\Lib\\site-packages\\pendulum\\parser.py\", line 36, in parse\n return _parse(text, **options)\n File \".venv\\Lib\\site-packages\\pendulum\\parser.py\", line 51, in _parse\n parsed = base_parse(text, **options)\n File \".venv\\Lib\\site-packages\\pendulum\\parsing\\__init__.py\", line 78, in parse\n return _normalize(_parse(text, **_options), **_options)\n ~~~~~~^^^^^^^^^^^^^^^^^^\n File \".venv\\Lib\\site-packages\\pendulum\\parsing\\__init__.py\", line 125, in _parse\n raise ParserError(f\"Unable to parse string [{text}]\")\npendulum.parsing.exceptions.ParserError: Unable to parse string [2001-01-01T12:34:56.1234567890]\n```\n\nPython's native datetime does not have issues with it:\n\n```python\n>>> datetime.datetime.fromisoformat(\"2001-01-01T12:34:56.1234567890Z\")\ndatetime.datetime(2001, 1, 1, 12, 34, 56, 123456, tzinfo=datetime.timezone.utc)\n```\n\nIt is expected that truncation (or even better rounding) to microseconds is applied independent of the number of digits present in the string.\n\nMy current workaround is to extract the fractional part of the seconds, parse it as a float, and then add it to the DateTime instance (which accomplishes the rounding):\n\n```python\n>>> pendulum.parse(\"2001-01-01T12:34:56Z\").add(seconds=float(\".1234567890\"))\nDateTime(2001, 1, 1, 12, 34, 56, 123457, tzinfo=Timezone('UTC'))\n```\n\nThe issue also happens when running in Linux (e.g., using the latest python3.14-slim container).","author":{"url":"https://github.com/dr-eme","@type":"Person","name":"dr-eme"},"datePublished":"2026-01-29T11:09:49Z","url":"https://github.com/python-pendulum/pendulum/issues/935"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /:user_id/:repository/issues/:id(.:format) |
| route-controller | issues |
| route-action | show |
| fetch-nonce | v2:b67e2a5f-eaa0-4aa6-2581-aa3d4707d7e0 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A322:1A4796:112CF1:18461D:6B0464B3 |
| html-safe-nonce | d438dd4c447c50161c65f41095ad3db81d48b9633554369dd66beb3fb3fab97e |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBMzIyOjFBNDc5NjoxMTJDRjE6MTg0NjFEOjZCMDQ2NEIzIiwidmlzaXRvcl9pZCI6IjUzMDc1MzMzMzg1MDMwNDYzMjQiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 892f834e028e3fa804794998ce78a1f2e44a308a9bc854895b9a831d8f98feb0 |
| hovercard-subject-tag | repository:62095504 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/python-pendulum/pendulum/issues/935 |
| twitter:image | https://opengraph.githubassets.com/547eefd129aac4abcc959b16d469b069c41f5ff0b3190d8d4e8e8942e427f87f/python-pendulum/pendulum |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/547eefd129aac4abcc959b16d469b069c41f5ff0b3190d8d4e8e8942e427f87f/python-pendulum/pendulum |
| og:image:alt | Python datetimes made easy. Contribute to python-pendulum/pendulum development by creating an account on GitHub. |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 2d58451b4bcb73c33c67bfb6b28fb75fe6d5e279daf9b560fa4fd832f3d8c9a6 |
| turbo-cache-control | no-cache |
| go-import | github.com/python-pendulum/pendulum git https://github.com/python-pendulum/pendulum.git |
| octolytics-dimension-user_id | 191041900 |
| octolytics-dimension-user_login | python-pendulum |
| octolytics-dimension-repository_id | 62095504 |
| octolytics-dimension-repository_nwo | python-pendulum/pendulum |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 62095504 |
| octolytics-dimension-repository_network_root_nwo | python-pendulum/pendulum |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 03e114520787ad27289207f153520ef97461127c |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width