0.2.0 #249
BurntSushi
announced in
Announcements
0.2.0
#249
Replies: 1 comment 3 replies
-
@BurntSushi There is a typo in the release note:
... should be I hit this breaking change and failed to find the text in the beginning. |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Sponsorship is appreciated!
This is a new semver incompatible release of Jiff. It contains several breaking
changes. I expect most users of Jiff to be able to upgrade without any changes.
The fundamental API organization of Jiff has not changed.
Some of the highlights of this release include reducing footguns and better
ecosystem integration.
For reducing footguns, APIs on
Span
will no longer implicitly assume thatdays are always 24 hours long. And
Span
no longer implementsPartialEq
orEq
(instead favoringspan.fieldwise()
to create a value that supports naivefieldwise comparison). Moreover, when using
TimeZone::system()
(perhaps viaZoned::now()
), if the system time zone could not be detected, then a specialEtc/Unknown
time zone will be used instead. This avoids erroring, but alsosurfaces itself to make it clearer that something has (perhaps) gone wrong.
As for ecosystem integration, this release coincides with the publication
of the
jiff-icu
,jiff-sqlx
andjiff-diesel
crates.jiff-icu
integrates with the ICU4X project, and is now the recommended way to use
Jiff to work with non-Gregorian calendars or to localize datetimes for end
users.
jiff-sqlx
andjiff-diesel
provide wrapper types that implement thenecessary traits to make it ergonomic to store and retrieve Jiff values in a
database using SQLx or Diesel, respectively.
Unless something unexpected happens, my plan is for the next breaking change
release to be Jiff 1.0 in about 6 months. Once Jiff 1.0 is out, I plan to
commit to it indefinitely.
BREAKING CHANGES:
This is an exhaustive list of breaking changes. Changes with the bolded
RUNTIME prefix are changes that will not be caught by the Rust compiler.
That is, they are changes in runtime behavior.
The deprecated
intz
routines onZoned
,Timestamp
,civil::DateTime
andcivil::Date
have been removed. You can usein_tz
instead. This change wasmade because many found the name
intz
to be unclear.The
PartialEq
andEq
trait implementations onSpan
have been removed.Ideally these shouldn't have been used, but if you do need them, please use
Span::fieldwise
to create aSpanFieldwise
, which does have thePartialEq
and
Eq
traits implemented. These were removed onSpan
itself because theymade it very easy to commit subtle bugs.
Turn panics during
Timestamp::saturing_add
into errors. Callers addingspans that are known to contain units of hours or smaller are guaranteed that
this will not return an error.
On
Span
APIs, days are no longer silently assumed to always be 24 hours whena relative datetime is not provided. Instead, to perform operations on units
of days or bigger, callers must either provide a relative date or opt into
invariant 24-hour days with
SpanRelativeTo::days_are_24_hours
. Shortcuts havebeen added to the span builders. For example,
SpanTotal::days_are_24_hours
.Change the behavior of the deprecated
%V
conversion specifier injiff::fmt::strtime
from formatting an IANA time zone identifier to formattingan ISO 8601 week number. To format an IANA time zone identifier, use
%Q
or%:Q
(which were introduced injiff 0.1
).When parsing into a
Zoned
with a civil time corresponding to a gap, we treatall offsets as invalid and return an error. Previously, we would accept the
offset as given. This brings us into line with Temporal's behavior. For
example, previously Jiff accepted
2006-04-02T02:30-05[America/Indiana/Vevay]
but will now return an error. This is desirable for cases where a datetime in
the future is serialized before a change in the daylight saving time rules.
For more examples, see
jiff::fmt::temporal::DateTimeParser::offset_conflict
for details on how to change Jiff's default behavior. This behavior change also
applies to
tz::OffsetConflict::PreferOffset
.Tweak the semantics of
tz::TimeZoneDatabase
so that it only initializes oneinternal tzdb instead of trying to find as many as possible. It is unlikely
that you'll be impacted by this change, but it's meant to make the semantics
be a bit more sensible. (In
jiff 0.1
, it was in theory possible for one tzlookup to succeed in the system zoneinfo and then another tz lookup to fail
in zoneinfo but succeed automatically via the bundled copy. But this seems
confusing and possibly not desirable. Hence the change.)
In order to make naming a little more consistent between
Zoned
and
civil::Date
, thecivil::Date::to_iso_week_date
andcivil::ISOWeekDate::to_date
APIs were renamed tocivil::Date::iso_week_date
and
civil::ISOWeekDate::date
.Remove
Span::to_duration
for converting aSpan
to astd::time::Duration
and rename
Span::to_jiff_duration
toSpan::to_duration
. This prioritizesSignedDuration
as the "primary" non-calendar duration type in Jiff. And makesit more consistent with APIs like
Zoned::duration_since
. For non-calendarspans, the
TryFrom<Span> for std::time::Duration
still exists. For calendardurations, use
Span::to_duration
and then convert theSignedDuration
tostd::time::Duration
. Additionally,Timestamp::from_jiff_duration
andTimestamp::as_jiff_duration
were renamed toTimestamp::from_duration
andTimestamp::as_duration
, respectively. The old deprecated routines on theunsigned
std::time::Duration
have been removed.Change the type of the value yielded by the
jiff::tz::TimeZoneNameIter
iterator from
String
tojiff::tz::TimeZoneName
. This opaque type is moreAPI evolution friendly. To access the string, either use
TimeZoneName
'sDisplay
trait implementation, or itsas_str
method.Split
TimeZone::to_offset
into two methods. One that just returns theoffset, and another,
TimeZone::to_offset_info
, which includes the offset,DST status and time zone abbreviation. The extra info is rarely needed and
is sometimes more costly to compute. Also, make the lifetime of the time
zone abbreviation returned by
TimeZoneTransition::abbreviation
tied tothe transition instead of the time zone (for future API flexibility, likely
in core-only environments). This change was overall motivated by wanting to
do less work in the common case (where we only need the offset), and for
reducing the size of a
TimeZone
considerably in core-only environments.Callers previously using
TimeZone::to_offset
to get DST status and time zoneabbreviation should now use
TimeZone::to_offset_info
.When
TimeZone::system()
cannot find a system configured time zone,jiff 0.1
would automatically fall back toTimeZone::UTC
(with a WARN-level logmessage). In
jiff 0.2
, the fall back is now toTimeZone::unknown()
, whichhas a special
Etc/Unknown
identifier (as specified by Unicode and reserved bythe IANA time zone database). The fallback otherwise still behaves as if it
were
TimeZone::UTC
. This helps surface error conditions related to findingthe system time zone without causing unrecoverable failure.
Enhancements:
When the special
SpanRelativeTo::days_are_24_hours()
marker is used, weekswill also be treated as invariant. That is, seven 24-hour days. In all cases,
working with years and months still requires a relative date.
It is now possible to forcefully use a bundled copy of the IANA time zone
database without relying on disabling crate features. This can be done by
enabling the
tzdb-bundle-always
crate feature and explicitly creating ajiff::tz::TimeZoneDatabase::bundled()
database. Once in hand, you must useAPIs like
TimeZoneDatabase::get
to create aTimeZone
and avoid any APIsthat implicitly use the global time zone database (like
Timestamp::in_tz
oreven
Zoned::from_str
).Add integration with the ICU4X project via the
jiff-icu
crate.jiff-icu
provides traits for easily converting between datetime types defined in Jiff
and datetime types defined in ICU4X.
Add integration with the SQLx project via the
jiff-sqlx
crate.jiff-sqlx
provides wrapper types that implement the necessary traits in SQLx for
reasonably ergonomic integration. This includes PostgreSQL and SQLite support,
but not MySQL support. (It's not clear if it's possible at present to provide
MySQL supprot fro SQLx for datetime types outside of SQLx itself.)
Add integration with the Diesel project via the
jiff-diesel
crate.jiff-diesel
provides wrapper types that implement the necessary traits inDiesel for reasonably ergonomic integration. This includes MySQL, PostgreSQL
and SQLite support.
This discussion was created from the release 0.2.0.
Beta Was this translation helpful? Give feedback.
All reactions