0.9.0rc1
Pre-releaseA small addition to 0.9.0rc0 that fixes some bugs, and makes the transition from format/parse_common_iso to format/parse_iso easier by deprecating (not removing) the old names. Full list of changes since 0.8.9 below:
Breaking Changes
-
SystemDateTimehas been removed and its functionality is now integrated intoZonedDateTime.
Migration:SystemDateTime.now()can be replaced withInstant.now().to_system_tz().to_system_tz()andassume_system_tz()now return aZonedDateTimeinstead of aSystemDateTime.
Rationale: The
SystemDateTimeclass was an awkward corner of the API,
creating inconsistencies and overlapping withZonedDateTime.
This change unifies the API, providing a single, consistent way to handle
all timezone-aware datetimes. The original use cases are fully supported
by the improvedZonedDateTime. -
ZonedDateTimeinstances with a system timezone may in rare cases
not have a known IANA timezone ID (thetzproperty will beNone).
This is an unfortunate limitation of some platforms.
SuchZonedDateTimeinstances can still be used for all operations,
and will account for DST correctly. However, these instances cannot be pickled,
and their ISO format will not be able to include the timezone ID.Rationale: This is an necessary compromise for broad system timezone support.
Other libraries (and Python's ownzoneinfo) have similar limitations. -
All classes can now be directly instantiated from an ISO 8601 formatted string
passed as a sole argument. For example,Date("2023-10-05")is equivalent to
Date(2023, 10, 5)(which is still supported, of course).
Therepr()of all classes now includes quotes, so that the output
can be directly used as input and thuseval(repr(obj)) == obj.Rationale: This makes the types a lot easier to use in interactive sessions
and tests. It also makesrepr()round-trippable, which is a common
expectation for primitive types. -
Renamed
[format|parse]_common_isomethods to[format|parse]_iso.
The old methods are still available (but deprecated) to ease the transition.Rationale: The "common" qualifier is no longer necessary because
these methods have been expanded to handle a wider range of ISO 8601 formats. -
Removed the deprecated
local()methods (useto_plain()instead). -
Removed the deprecated
instant()method (useto_instant()instead).
Improved
-
Customizable ISO 8601 Formatting: The
format_iso()methods now accept
parameters to customize the output. You can control theseparator
(e.g.,'T'or' '), the smallestunit(fromhourtonanosecond),
and toggle thebasic(compact) orextendedformat.Also, the formatting is now significantly faster. Up to 5x faster for
ZonedDateTime, which is now 10x faster than the standard library'sdatetime.isoformat().
Fixed
- Resolved a memory leak in the Rust extension where timezone objects that
were no longer in use were not properly evicted from the cache. - Fixed a rare bug in determining the UTC offset for times far in the future
- Fixed
PlainDateTimeconstructor raisingTypeErrorinstead of
ValueErrorwhen passed invalid parameters. - TZ IDs starting with a
./are now properly rejected. Other path traversal
attempts were already handled correctly. - More robust timezone refcounting in the Rust extension, preventing crashes
in rare cases (#270) - Panics in Rust extension no longer crash the interpreter, raise
RuntimeErrorinstead