This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author orent
Recipients orent
Date 2017-10-22.04:56:06
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
The object types in the datetime module can produce a standard string representation (rfc3339, a subset of iso8601) but they do not provide a method to parse it.

Proposed method names: isoparse or fromisoformat.

In addition, a constructor call with a single string argument may also be supported. This would make the behavior of datetime/date/time more similar to other value types such as int, str or float and maintain the same invariant of x == type(x)(str(x))

Requirements: support lossless round-tripping of all valid datetime object values to str and back, with the exception of objects having a custom tzinfo (not None or an instance of datetime.timezone).

The _strptime format of '%Y-%m-%d %H:%M:S.%f%z' comes close, but fails to meet these requirements in the following ways:

1. %z matches +HHMM, not +HH:MM (addressed by issue 31800, currently discussed on datetime-sig)
2. %z does not match the empty string, indicating a naive datetime object (tzinfo=None)
3. .%f requires a fraction part, while isoformat drops it when the timestamp is an exact second (microsecond=0).
Date User Action Args
2017-10-22 04:56:08orentsetrecipients: + orent
2017-10-22 04:56:08orentsetmessageid: <>
2017-10-22 04:56:08orentlinkissue31839 messages
2017-10-22 04:56:06orentcreate