Skip to content

Inconsistent behavior of datetime.strftime #131502

@mouchen626

Description

@mouchen626

Bug report

Bug description:

The datetime.strftime("%1") format specifier produces different results on Windows and Linux. This discrepancy may cause unexpected behavior in cross-platform applications.

from datetime import datetime
dt = datetime.now()
s = dt.strftime("%1")
print(s)

Windows: Raises an ValueError.
Linux: Returns "%1".

CPython versions tested on:

3.11

Operating systems tested on:

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions