Skip to content

0.9.0rc1

Pre-release
Pre-release

Choose a tag to compare

@ariebovenberg ariebovenberg released this 25 Sep 18:51
· 35 commits to main since this release

A 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

  • SystemDateTime has been removed and its functionality is now integrated into ZonedDateTime.
    Migration:

    • SystemDateTime.now() can be replaced with Instant.now().to_system_tz().
    • to_system_tz() and assume_system_tz() now return a ZonedDateTime instead of a SystemDateTime.

    Rationale: The SystemDateTime class was an awkward corner of the API,
    creating inconsistencies and overlapping with ZonedDateTime.
    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 improved ZonedDateTime.

  • ZonedDateTime instances with a system timezone may in rare cases
    not have a known IANA timezone ID (the tz property will be None).
    This is an unfortunate limitation of some platforms.
    Such ZonedDateTime instances 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 own zoneinfo) 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).
    The repr() of all classes now includes quotes, so that the output
    can be directly used as input and thus eval(repr(obj)) == obj.

    Rationale: This makes the types a lot easier to use in interactive sessions
    and tests. It also makes repr() round-trippable, which is a common
    expectation for primitive types.

  • Renamed [format|parse]_common_iso methods 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 (use to_plain() instead).

  • Removed the deprecated instant() method (use to_instant() instead).

Improved

  • Customizable ISO 8601 Formatting: The format_iso() methods now accept
    parameters to customize the output. You can control the separator
    (e.g., 'T' or ' '), the smallest unit (from hour to nanosecond),
    and toggle the basic (compact) or extended format.

    Also, the formatting is now significantly faster. Up to 5x faster for
    ZonedDateTime, which is now 10x faster than the standard library's datetime.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 PlainDateTime constructor raising TypeError instead of
    ValueError when 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 RuntimeError instead