datetime.strptime's %z should support +HH
未關閉
還沒有人認領這個 Issue。
stdlib
type-feature
- 主要語言
- Python
- 星號
- 77.2k
- 分支
- 35.9k
- PR 合併指標
- PR 指標待擷取
描述
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
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
從 datetime.strptime() 對 %z 指示詞的處理開始,並將其與 datetime.fromisoformat() 進行比較,以 issue 中的 +01 範例作為行為參考。檢查相同的考量是否適用於 %:z;當文件所述的 offset 形式能一致地被接受,且該範例有涵蓋時,即視為完成。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- python
- 領域
- backend
- Issue 類型
- 功能
- 難度
- 3/5
- 預估耗時
- 1-2 天
- 活躍度
- 停滯
- 描述清晰度
- 描述清楚
- 新手友好度
- 25/100