Skip to content

gh-137165: Unify datetime.strftime behavior for unsupported non-zero-padded specifiers#145018

Open
F0RRZZ wants to merge 2 commits intopython:mainfrom
F0RRZZ:issue-137165-unify-invalid-zp-behaviour
Open

gh-137165: Unify datetime.strftime behavior for unsupported non-zero-padded specifiers#145018
F0RRZZ wants to merge 2 commits intopython:mainfrom
F0RRZZ:issue-137165-unify-invalid-zp-behaviour

Conversation

@F0RRZZ
Copy link
Contributor

@F0RRZZ F0RRZZ commented Feb 19, 2026

This PR unifies the behavior of datetime.strftime when encountering unsupported or invalid non-zero-padded specifiers across different platforms.

Previously, the behavior for invalid specifiers was inconsistent:
Windows: Raised a ValueError
macOS/FreeBSD: Could return partial strings or stripped characters (e.g., returning # instead of %-#).
Linux: Echoes the specifier back as-is (e.g., %-#).

The behavior is now unified to match Linux.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments