datetime.strptime's %z should support +HH
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 77.2k
- Forks
- 35.9k
- PR merge metrics
- PR metrics pending
Description
Feature or enhancement
Proposal:
The %z directive supports the UTC offset in the form ±HHMM[SS[.ffffff]]. Other parsing functions like fromisoformat on the other hand support the full format ±HH[MM[SS[.ffffff]]]. So there is no strptime format that supports the fromisoformat.
from datetime import datetime
datetime.fromisoformat("2023-05-25T15:35:05.666+01") # ok
datetime.strptime("2023-05-25T15:35:05.666+01", "%Y-%m-%dT%H:%M:%S.%f%z") # nok
The same may apply to %:z (https://github.com/python/cpython/issues/121237)
Has this already been discussed elsewhere?
This is a minor feature, which does not need previous discussion elsewhere
Links to previous discussion of this feature:
No response
Linked PRs
- gh-130390
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the datetime.strptime() handling of the %z directive and compare it with datetime.fromisoformat(), using the issue's +01 example as the behavioral reference. Check whether the same consideration applies to %:z; done means the documented offset form is accepted consistently, with coverage for the example.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 25/100