whenever

⏰ Modern datetime library for Python, available in Rust or pure Python

MIT License

Downloads
36.2K
Stars
804
whenever - 0.6.8 Latest Release

Published by ariebovenberg about 2 months ago

Fix object deallocation bug that caused a crash in rare cases (#167)

whenever - 0.6.7

Published by ariebovenberg 3 months ago

  • Add Python 3.13 binary wheels, now that its ABI is stable
  • Small improvements to import speed
whenever - 0.6.6

Published by ariebovenberg 3 months ago

Fix potential memory leak in .now() if time-machine is used

whenever - 0.6.5

Published by ariebovenberg 3 months ago

  • from_timestamp now also accepts floats, to ease porting code from datetime (#159)
  • Fixed incorrect fractional seconds when parsing negative values in from_timestamp methods.
  • Fix some places where ValueError was raised instead of TypeError
whenever - 0.6.4

Published by ariebovenberg 3 months ago

  • Add helper patch_current_time for patching current time in whenever (only) (#147)
  • Support patching the current time with time-machine (#147)
  • Remove undocumented year/month/day/offset properties from Instant
  • Reduce size of binary distributions
  • Clarify contribution guidelines
whenever - 0.6.3

Published by ariebovenberg 3 months ago

  • Improve robustness and speed of keyword argument parsing in Rust extension (#149)
  • Add more answers to common questions in the docs and FAQ (#148, #150)
whenever - 0.6.2

Published by ariebovenberg 3 months ago

Add third-party licenses to distributions

whenever - 0.6.1

Published by ariebovenberg 4 months ago

Small updates to project metadata

whenever - 0.6.0

Published by ariebovenberg 4 months ago

🎉 A big release touting a Rust extension module and an API more consistent with other modern libraries.

Added or improved

  • Implement as a Rust extension module, leading to a big speedup
  • Add replace_date and replace_time methods to datetimes.
  • Add Date.MIN and Date.MAX constants.
  • from_py_* methods are more robust.
  • The pickle format for most types is now more efficient.

Breaking changes

(see the changelog for the full rationale behind each change)

  • UTCDateTime is now Instant. Removed methods that were specific to UTC.
  • NaiveDateTime is now LocalDateTime
  • Nanosecond precision is now the default for all datetimes and deltas. nanosecond is a keyword-only argument for all constructors, to prevent mistakes porting code from datetime (which uses microseconds).
  • Unified [from_]canonical_format methods with [from_]common_iso8601 methods into [format|parse]_common_iso methods.
  • Timestamp methods now use integers instead of floats. There are now separate methods for seconds, milliseconds, and nanoseconds.
  • Renamed [from_][rfc3339|rfc2822] methods to [format|parse]_[rfc3339|rfc2822].
  • Added explicit ignore_dst=True flag to DST-unsafe operations such as shifting an offset datetime.
  • Renamed as_utc, as_offset, as_zoned, as_local to to_utc, to_fixed_offset, to_tz, to_system_tz, and the NaiveDateTime.assume_* methods accordingly
  • disambiguate= is non-optional for all relevant methods. The only exception is the constructor, which defaults to "raise".
  • Removed weakref support.
  • Weekdays are now an enum instead of an integer.
  • Calendar units in Date[Time]Delta can now only be retrieved together. For example, there is no delta.months or delta.days anymore,delta.in_months_days() should be used in this case.
  • Units in delta cannot be different signs anymore (after normalization).
  • Calendar units are normalized, but only in so far as they can be converted strictly. For example, 1 year is always equal to 12 months, but 1 month isn't equal to a fixed number of days. Refer to the delta docs for more information.
  • Renamed AmbiguousTime to RepeatedTime.
  • Dropped Python 3.8 support
whenever - 0.5.2

Published by ariebovenberg 6 months ago

Add Date.py_date() (#118)

whenever - 0.5.1

Published by ariebovenberg 7 months ago

Fix LocalSystemDateTime.now() not setting the correct offset (#104)

whenever - 0.5.0

Published by ariebovenberg 7 months ago

Breaking changes

  • Fix handling of -0000 offset in RFC2822 format, which was not according to the standard. NaiveDateTime can now no longer be created from this format.
  • DateDelta canonical format now uses P prefix.

Improved

  • Add explicit ISO8601 formatting/parsing methods to datetimes, date, time, and deltas.
  • Add missing Date.from_canonical_format method.
  • Separate docs for deltas and datetimes.
  • NaiveDateTime.assume_offset now also accepts integers as hour offsets.
whenever - 0.4.0

Published by ariebovenberg 8 months ago

A big release with the main feature being the addition of date/time deltas.
I've also tried to bundle as many small breaking changes as possible into
this release, to avoid having to do them in the future.

For the rationale behind each breaking change, see the full changelog

Breaking changes

  • LocalDateTime renamed to LocalSystemDateTime.
  • LocalSystemDateTime no longer adjusts automatically to changes in the system timezone. Now, LocalSystemDateTime reflects the system timezone at the moment of instantiation. It can be updated explicitly.
  • The disambiguate= argument now also determines how non-existent times are handled.
  • from_naive() removed in favor of methods on NaiveDateTime. For example, UTCDateTime.from_naive(n) becomes n.assume_utc().
  • Renamed ZonedDateTime.disambiguated() to .is_ambiguous().
  • Replaced .py property with .py_datetime() method.
  • Removed properties that simply delegated to the underlying datetime object: tzinfo, weekday, and fold. date and time now return whenever.Date and whenever.Time objects.
  • Renamed .canonical_str() to .canonical_format().
  • Renamed DoesntExistInZone to SkippedTime, Ambiguous to AmbiguousTime.
  • Renamed min and max to MIN and MAX.

Improved

  • Added a disambiguation="compatible" option that matches the behavior of other languages and the RFC5545 standard.
  • Shortened the repr() of all types, use space separator instead of T.
  • Added sep="T" or " " option to canonical_format()
  • OffsetDateTime constructor and methods creating offset datetimes now accept integers as hour offsets.
  • Added Date and Time classes for working with dates and times separately.
whenever - 0.3.4

Published by ariebovenberg 9 months ago

Improved exception messages for ambiguous or non-existent times (#26)

whenever - 0.3.3

Published by ariebovenberg 9 months ago

💾 Add CPython-maintained tzdata package as Windows dependency (#32)

whenever - 0.3.2

Published by ariebovenberg 9 months ago

🔓 Relax overly strict Python version constraint in package metadata (#33)

whenever - 0.3.1

Published by ariebovenberg 9 months ago

📦 Fix packaging metadata issue involving README and CHANGELOG being installed in the wrong place (#23)

whenever - 0.3.0

Published by ariebovenberg 9 months ago

Breaking changes

  • 🥒 Change pickle format so that backwards-compatible unpickling is possible in the future.

Added

  • 🔨 Added strptime() to UTCDateTime, OffsetDateTime and NaiveDateTime.
  • 📋 Added rfc2822()/from_rfc2822() to UTCDateTime, OffsetDateTime and NaiveDateTime.
  • ⚙️ Added rfc3339()/from_rfc3339() to UTCDateTime and OffsetDateTime
whenever - 0.2.1

Published by ariebovenberg 9 months ago

  • added days() timedelta alias
  • Improvements to README, other docs
whenever - 0.2.0

Published by ariebovenberg 10 months ago

Breaking changes

  • 📐Disambiguation of local datetimes is now consistent with zoned datetimes, and is also run on replace().

  • 👌Renamed:

    • from_strfrom_canonical_str
    • to_utc/offset/zoned/localas_utc/offset/zoned/local.
    • ZonedDateTime.zoneZonedDateTime.tz

Added

  • ⚖️ Support comparison between all aware datetimes
  • 🧮Support subtraction between all aware datetimes
  • 🍩 Convenience methods for converting between aware/naive
  • 💪 More robust handling of zoned/local edge cases

Docs

  • Cleaned up API reference
  • Added high-level overview