Enhancement Proposal: Standardized Support for Non-Zero-Padded Day and Month Formatting in datetime.strftime
まだ誰も着手していません。
- 主要言語
- Python
- スター
- 77.2k
- フォーク
- 36k
- PR マージ指標
- PR 指標を取得中
説明
Feature or enhancement
Proposal:
Python's datetime.datetime.strftime supports formatting directives for dates and times, such as %d for zero-padded days and %m for zero-padded months.
While there are platform-specific ways to get non-zero-padded day (%-d on Unix) or month (%-m), these do not work reliably across all platforms.. Particularly between Unix-like systems and Windows.
from datetime import datetime
dt = datetime(2025, 6, 6)
# On Unix:
dt.strftime("%-d. %-m. %Y") # '6. 6. 2025'
# On Windows:
dt.strftime("%-d. %-m. %Y") # Raises ValueError
I understand that strftime relies on the underlying C library for formatting, which is probably why this behavior differs between platforms. That said, if it's not practical to change this at the core level, maybe there could be some kind of wrapper or Python-level normalization to make things more consistent across systems.
Currently this requires a workaround such as usage of .format directly on the datetime object.
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-138982
- gh-139002
- gh-139088
- gh-145018
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
datetime.datetime.strftime から始め、Unix 系システムおよび Windows で、そのディレクティブが基盤となる C ライブラリにどのように依存しているかを調査してください。開始する前にリンクされている PRs を確認してください。すべてのプラットフォームで、日と月をゼロ埋めなしでフォーマットするための一貫した方針が決定されれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- operating-systems
- issue の種類
- 機能追加
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 20/100