Skip to content

Replace chrono with jiff for timestamps - #618

Open
HackingGate wants to merge 1 commit into
nextest-rs:mainfrom
HackingGate:replace-chrono-with-jiff
Open

HackingGate wants to merge 1 commit into
nextest-rs:mainfrom
HackingGate:replace-chrono-with-jiff

Conversation

@HackingGate

Copy link
Copy Markdown

chrono is now flagged as unmaintained (RUSTSEC-2026-0543, from chronotope/chrono#1768). The advisory recommends jiff or time. This PR replaces chrono with jiff 1.0, which also answers the question in #429 about how timestamps would be stored without chrono.

Related: #429

Changes

  • Breaking: the timestamp fields and set_timestamp methods on Report, TestSuite, TestCase and TestRerun now use jiff::ZonedDateTime instead of chrono::DateTime<FixedOffset>.
    • ZonedDateTime is jiff's type for an instant together with an offset, so it keeps the UTC offset that the XML carries. A bare jiff::Timestamp would lose it.
    • Equality compares the instant only, the same as chrono's DateTime.
  • Serialization is unchanged: the same %Y-%m-%dT%H:%M:%S%.3f%:z format, for example 2021-04-01T10:52:37.000-08:00. A zero offset is still written as +00:00, never Z, and fractional seconds are truncated to milliseconds. The golden fixtures are byte-for-byte unchanged.
  • Deserialization reads the timestamp with jiff::fmt::temporal::Pieces and keeps its offset as a fixed-offset time zone. A value without a time, without an offset, or with a [...] time zone annotation is rejected with ParseTimestampError.
  • MSRV: raised from 1.79 to 1.85, because jiff 1.0 requires it. I updated rust-version, the MSRV CI job, lib.rs and the README badge and text. jiff 0.2 would keep 1.79, but this type is part of the public API, so 1.0 avoids a second breaking change later.
  • Dependencies: jiff is used with default-features = false, features = ["std"], so it pulls in no tzdb or system time zone code. The normal dependency tree loses chrono and num-traits and gains jiff and jiff-core.
  • Changelog: I added an entry under Unreleased, with a migration note.

Behaviour differences when parsing

jiff's parser accepts some ISO 8601 forms that DateTime::parse_from_rfc3339 rejects:

  • a comma as the decimal separator
  • times without seconds
  • the basic format, for example 20230101T000000Z
  • offsets written as +0530 or +05
  • six-digit years

It also reads the leap second 23:59:60 as 23:59:59. Every input that chrono accepted is still accepted, and gives the same output. I compared the two parsers on these cases in a separate crate.

Tests

  • Ported the existing tests from chrono to jiff.
  • Added a test that rejects non-RFC 3339 timestamps.
  • Added a wire-format test covering a +00:00 offset, millisecond truncation, a +05:45 offset, and keeping the offset across a round trip.
  • These all pass:
    • cargo nextest run --all-features on stable and on 1.85
    • cargo clippy --all-targets -D warnings with no features, with proptest, with internal-testing and with all features
    • cargo xfmt --check
    • cargo doc --all-features
    • doctests
    • cargo check in fuzz/

chrono is unmaintained (RUSTSEC-2026-0543), and its maintainer recommends
jiff. Timestamps are now `jiff::ZonedDateTime` instead of
`chrono::DateTime<FixedOffset>`. The serialized form is unchanged, and
deserialized timestamps keep their UTC offset as a fixed-offset time zone.

jiff 1.0 requires Rust 1.85, so the MSRV moves from 1.79 to 1.85.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant