Title: datetime.fromisoformat() accepts day 0 and year 0 combined with a 24:00 time · Issue #162306 · python/cpython · GitHub
Open Graph Title: datetime.fromisoformat() accepts day 0 and year 0 combined with a 24:00 time · Issue #162306 · python/cpython
X Title: datetime.fromisoformat() accepts day 0 and year 0 combined with a 24:00 time · Issue #162306 · python/cpython
Description: Bug report Bug description: datetime.fromisoformat() accepts a day of 00 or a year of 0000 when the time is 24:00, and returns the following date instead of raising ValueError. With any other time, the same dates are rejected. >>> from d...
Open Graph Description: Bug report Bug description: datetime.fromisoformat() accepts a day of 00 or a year of 0000 when the time is 24:00, and returns the following date instead of raising ValueError. With any other time,...
X Description: Bug report Bug description: datetime.fromisoformat() accepts a day of 00 or a year of 0000 when the time is 24:00, and returns the following date instead of raising ValueError. With any other time,...
Opengraph URL: https://github.com/python/cpython/issues/162306
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"datetime.fromisoformat() accepts day 0 and year 0 combined with a 24:00 time","articleBody":"# Bug report\n\n### Bug description:\n\n`datetime.fromisoformat()` accepts a day of `00` or a year of `0000` when the time is `24:00`, and returns the following date instead of raising `ValueError`. With any other time, the same dates are rejected.\n\n```python\n>>> from datetime import datetime\n>>> datetime.fromisoformat(\"2026-06-00T23:00\")\nTraceback (most recent call last):\n ...\nValueError: day 0 must be in range 1..30 for month 6 in year 2026\n>>> datetime.fromisoformat(\"2026-06-00T24:00\")\ndatetime.datetime(2026, 6, 1, 0, 0)\n>>> datetime.fromisoformat(\"0000-12-31T24:00\")\ndatetime.datetime(1, 1, 1, 0, 0)\n```\n\nThe C and pure-Python implementations behave the same. Before rolling `24:00` over to the next day, both check the month range and that the day is not past the end of the month, but not that the day is at least 1 or that the year is at least `MINYEAR`. The rolled-over date is valid, so the constructor accepts it.\n\ngh-151770 added the missing lower bound for the month in the same check. This is the same gap for the day and the year. I have a fix with tests and will open a PR.\n\n3.13 and earlier are not affected because they reject hour 24 (support came with gh-102450). Reproduced on 3.14.10 and 3.15.2 (Windows), 3.14.7 (Linux), and a debug build of `main` at b09a7e92fb (Linux).\n\n### CPython versions tested on:\n\n3.14, 3.15, CPython main branch\n\n### Operating systems tested on:\n\nLinux, Windows\n\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-162307\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/choam2426","@type":"Person","name":"choam2426"},"datePublished":"2026-11-20T04:51:20Z","url":"https://github.com/python/cpython/issues/162306"}
| 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 | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:a9d84171-3707-060d-c69f-1285a07d0d7b |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | AC92:1DC4CC:117BEFC:174BECE:6B01E955 |
| html-safe-nonce | e9680d2fe804aeac6377239da2186273412e121e9d134c626dd9fafa87b87a12 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBQzkyOjFEQzRDQzoxMTdCRUZDOjE3NEJFQ0U6NkIwMUU5NTUiLCJ2aXNpdG9yX2lkIjoiNTM1MzcyMDE0MTE5ODc4MDc1NyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 03d23b072a9cb298f74dbaa3a20a9db3c1b26be7213e46b5b5d36663f7a6dd6a |
| hovercard-subject-tag | issue:6505045315 |
| 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/_view_fragments/issues/show/python/cpython/162306/issue_layout |
| twitter:image | https://opengraph.githubassets.com/287e4f5c0885d1423c115324530c0920e9cc39d3f74c62c5d47a9fe90f76b4bb/python/cpython/issues/162306 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/287e4f5c0885d1423c115324530c0920e9cc39d3f74c62c5d47a9fe90f76b4bb/python/cpython/issues/162306 |
| og:image:alt | Bug report Bug description: datetime.fromisoformat() accepts a day of 00 or a year of 0000 when the time is 24:00, and returns the following date instead of raising ValueError. With any other time,... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | choam2426 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| 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 | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width