Skip to content

Add support for ISO 8601 ordinal dates format #163170

Backlog

Description

@Hatovix

Feature or enhancement

The ordinal dates format from ISO 8601 are currently unsupported by the fromisoformat methods in datetime module, as stated in the documentation in both date and datetime:

This format is composed of 2 parts:

  • Year: YYYY (exactly 4 digits)
  • Day of the year: DDD (exactly 3 digits)

Like the 2 other formats from the standard (calendar dates and week dates), it can be used with or without the - separator.
Example of usage inspired from the current doc:

>>> import datetime as dt
>>> dt.date.fromisoformat('2019-338')
datetime.date(2019, 12, 4)
>>> dt.datetime.fromisoformat('2011-308 00:05:23.283')
datetime.datetime(2011, 11, 4, 0, 5, 23, 283000)

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

Activity

  1. added
    type-feature
    on Dec 4, 2026
  2. gvanrossum commented on Dec 4, 2026

    @gvanrossum
    Member

    Do you have a need for this in a real application? Or is this just completionism?

  3. Hatovix commented on Dec 4, 2026

    @Hatovix
    Author

    It is completionism, I was surprised to see the unsupported mention in the doc

  4. gvanrossum commented on Dec 4, 2026

    @gvanrossum
    Member

    I don't believe we've ever received a request for this feature. (I personally think it would be a misfeature, because it's not human-readable.)

  5. added
    pending
    extension-modules
    on Dec 5, 2026
  6. removed
    pending
    on Dec 5, 2026
  7. added
    stdlib
    on Dec 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    extension-modulesstdlibtype-feature

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions