Repository navigation
delorean 2.0.0 is on PyPI: https://pypi.org/project/delorean/2.0.0/
The first release since 1.0.0 in February 2018. Timezones move to the standard library, and every fix that had accumulated on master ships with it.
Breaking changes
- Timezones are now standard library objects.
Delorean.timezonereturns a
zoneinfo.ZoneInfofor a named zone or adatetime.timezonefor a fixed
offset, andpytzis no longer a dependency. Comparisons such as
d.timezone == pytz.utcbecomed.timezone == delorean.utc. (#79) midnight,start_of_dayandend_of_dayreturnDeloreanobjects
rather than baredatetimeobjects, so they compose with the shift methods.
Callers doingd.midnight.strftime(...)needd.midnight.datetime. (#139)- A local time that occurs twice, on the autumn daylight saving transition, now
resolves to the first of its two occurrences, following the standard library's
fold=0. Earlier versions resolved it to standard time via pytz's
is_dst=False. Times inside the spring-forward gap are unchanged. - An unknown timezone name raises
DeloreanInvalidTimezone, which is a
ValueError, instead ofpytz.UnknownTimeZoneError. localize()rejects an already-aware datetime instead of silently replacing
its timezone, which moved the instant the value represented.repr()prints a fixed offset as'UTC-08:00'rather than
pytz.FixedOffset(-480). The constructor accepts that string, so repr output
still round-trips througheval().
Added
parse()takes a keyword-onlyassume_timezone, which controls the
timezone applied to a string that carries none. It defaults to"UTC",
matching earlier behaviour, and acceptsNoneto reject such input instead. (#53)delorean.timezone()anddelorean.utc, so callers never import a
timezone library of their own.timezone()accepts an IANA name, a fixed
offset written as"UTC-08:00", or an existingtzinfoobject. (#79)start_of_month,end_of_month,start_of_yearandend_of_year. (#85)Delorean.timestampandfrom_timestamp(), naming the value for what it
is.epochremains as an alias. (#86)
Changed
- Note for upgraders:
delorean.dates.UTC, an undocumented constant equal to
the string"UTC", was removed back in 0.6.0. Use"UTC"or
delorean.utc. (#95) - Packaging moved to
pyproject.tomlwith hatchling, and the version is
single-sourced there. Documentation gained executed examples throughout,
covering daylight saving resolution and month-end clamping (#11). DeloreanErrorsubclassesValueError, so oneexcept ValueError
covers both delorean's errors and the parser's error for unreadable input. It
is also exported from the package root.
Fixed
- Fractional second shifts no longer truncate to zero.
next_second(0.5)moves
half a second, and calendar units reject non-integer counts with a
TypeErrorrather than silently doing nothing. (#75) - ISO 8601 strings parse correctly. This fix has been on master since 2018 and
reaches a release for the first time here. (#103) Delorean.__getattr__returned theAttributeErrorclass instead of
raising it, sohasattr()reportedTruefor invalid shift names.now()raisedAttributeErrorunder tzlocal 5.x, which returns a
zoneinfozone where delorean called pytz-only methods.normalize()hit
the same fault for any datetime delorean had itself localized.
Removed
- Python 3.9 is no longer supported;
requires-pythonis now>=3.10.