Skip to content

Add ISO Basic format support to datetime.isoformat() and date.isoformat() #118948

Open
@mohd-akram

Description

@mohd-akram

Feature or enhancement

Proposal:

In additional to the popular ISO 8601 Extended format, there's also an ISO 8601 Basic format for datetimes which is useful for filenames and URL components as it avoids characters such as eg. colon and is more compact. datetime.fromisoformat already supports parsing this format.

Example code:

datetime.isoformat(basic=True)
# 20240422T204705.335-0400
date.isoformat(basic=True)
# 20240422

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    extension-modulesC modules in the Modules dirstdlibPython modules in the Lib dirtype-featureA feature request or enhancement

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions