⏰ Modern datetime library for Python, available in Rust or pure Python
MIT License
Fix object deallocation bug that caused a crash in rare cases (#167)
Published by ariebovenberg 3 months ago
Published by ariebovenberg 3 months ago
Fix potential memory leak in .now()
if time-machine
is used
Published by ariebovenberg 3 months ago
from_timestamp
now also accepts floats, to ease porting code from datetime
(#159)from_timestamp
methods.ValueError
was raised instead of TypeError
Published by ariebovenberg 3 months ago
patch_current_time
for patching current time in whenever (only) (#147)year
/month
/day
/offset
properties from Instant
Published by ariebovenberg 3 months ago
Published by ariebovenberg 3 months ago
Add third-party licenses to distributions
Published by ariebovenberg 4 months ago
Small updates to project metadata
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
replace_date
and replace_time
methods to datetimes.Date.MIN
and Date.MAX
constants.from_py_*
methods are more robust.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
is a keyword-only argument for all constructors, to prevent mistakes porting code from datetime
(which uses microseconds).[from_]canonical_format
methods with [from_]common_iso8601
methods into [format|parse]_common_iso
methods.[from_][rfc3339|rfc2822]
methods to [format|parse]_[rfc3339|rfc2822]
.ignore_dst=True
flag to DST-unsafe operations such as shifting an offset datetime.as_utc
, as_offset
, as_zoned
, as_local
to to_utc
, to_fixed_offset
, to_tz
, to_system_tz
, and the NaiveDateTime.assume_*
methods accordinglydisambiguate=
is non-optional for all relevant methods. The only exception is the constructor, which defaults to "raise".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.AmbiguousTime
to RepeatedTime
.Published by ariebovenberg 6 months ago
Add Date.py_date()
(#118)
Published by ariebovenberg 7 months ago
Fix LocalSystemDateTime.now()
not setting the correct offset (#104)
Published by ariebovenberg 7 months ago
Breaking changes
-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
Date.from_canonical_format
method.NaiveDateTime.assume_offset
now also accepts integers as hour offsets.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.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()
.ZonedDateTime.disambiguated()
to .is_ambiguous()
..py
property with .py_datetime()
method.datetime
object: tzinfo
, weekday
, and fold
. date
and time
now return whenever.Date
and whenever.Time
objects..canonical_str()
to .canonical_format()
.DoesntExistInZone
to SkippedTime
, Ambiguous
to AmbiguousTime
.min
and max
to MIN
and MAX
.Improved
disambiguation="compatible"
option that matches the behavior of other languages and the RFC5545 standard.repr()
of all types, use space separator instead of T
.sep="T" or " "
option to canonical_format()
OffsetDateTime
constructor and methods creating offset datetimes now accept integers as hour offsets.Date
and Time
classes for working with dates and times separately.Published by ariebovenberg 9 months ago
Improved exception messages for ambiguous or non-existent times (#26)
Published by ariebovenberg 9 months ago
💾 Add CPython-maintained tzdata
package as Windows dependency (#32)
Published by ariebovenberg 9 months ago
🔓 Relax overly strict Python version constraint in package metadata (#33)
Published by ariebovenberg 9 months ago
📦 Fix packaging metadata issue involving README and CHANGELOG being installed in the wrong place (#23)
Published by ariebovenberg 9 months ago
Breaking changes
Added
strptime()
to UTCDateTime
, OffsetDateTime
and NaiveDateTime
.rfc2822()
/from_rfc2822()
to UTCDateTime
, OffsetDateTime
and NaiveDateTime
.rfc3339()
/from_rfc3339()
to UTCDateTime
and OffsetDateTime
Published by ariebovenberg 9 months ago
days()
timedelta aliasPublished 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_str
→ from_canonical_str
to_utc/offset/zoned/local
→ as_utc/offset/zoned/local
.ZonedDateTime.zone
→ ZonedDateTime.tz
Added
Docs