Replace chrono with jiff in the Rust SDK

Merged
JE
2d ago
+359-338

RUSTSEC-2026-0543 marks chrono unmaintained, and #307 put it on cargo-deny's ignore list until replacing it could be its own release. This is that change: the Rust SDK moves to jiff 1.x, and the ignore comes out. basecamp/basecamp-sdk#1106 makes the same change there.

Why jiff, and why now

  • chrono's maintainer soft-deprecated it in January (chronotope/chrono#1768), declined a handover, and held the advisory "until after the jiff 1.0 release". jiff 1.0 shipped 2026-11-15 with "an indefinite commitment to 1.x.y. Consumers of this library should feel confident about putting Jiff types into their public API." The floor is 1.0.1 (which fixes an out-of-bounds timestamp parse). Its MSRV is 1.85, under our 1.88, so rust-version doesn't move.
  • time was the other candidate. It is still 0.x and has no tz database, which Date::today and from_datetime_in need. Its OffsetDateTime serde isn't RFC 3339, so every generated field would need a with attribute.
  • The crate has no reverse dependencies on crates.io.

What changes

WasNow
DateTime = chrono::DateTime<Utc>jiff::Timestamp
Date(pub chrono::NaiveDate)Date(pub jiff::civil::Date)
<Date as FromStr>::Err = chrono::ParseErrorjiff::Error
Date::from_datetime_in<Tz: chrono::TimeZone>from_datetime_in(&DateTime, &jiff::tz::TimeZone)
Date::at_midnight_utc() -> DateTime-> Option<DateTime> (None only for 9999-12-31)
chrono::Weekday in Date::weekday and Identity::set_first_week_dayjiff::civil::Weekday
Token::expires_at: Option<DateTime<Utc>>Option<jiff::Timestamp>
(none)pub use jiff;

The generator only names crate::types::{Date, DateTime}, so no generated code changes. MIGRATING.md has the upgrade notes.

What stays the same, and how it was checked

  • Instants. I compared chrono's DateTime<Utc> serde with jiff's Timestamp serde. They agree on Z, numeric offsets, a space separator, lowercase t/z and nine fractional digits. Both refuse a missing offset and a bare date. Output is byte-identical. They differ only at the edges: a leap second reads as :59, and more than nine fractional digits is refused.
  • Dates. jiff's own date parser accepts 20260304 and 2026-03-04T00:00:00. Date therefore parses with strptime("%Y-%m-%d"), which matches chrono's %Y-%m-%d, unpadded 2026-3-4 included. tests/dates.rs now refuses both of those wider forms. Date::default() stays 1970-01-01 (jiff's own default is year zero). add_months/add_years keep Go's AddDate rollover, which jiff's clamping arithmetic would not.
  • Date::today(). jiff reads the zone with tz-system. Without a tz database it would silently fall back to UTC for a TZ=America/Chicago setting and on Windows and Android, so the crate enables tzdb-zoneinfo, tzdb-bundle-platform and tzdb-concatenated. Checked against chrono::Local with TZ unset, Pacific/Kiritimati, Etc/GMT+12 and an unknown zone: the same date in all four.
  • Retry-After. jiff::fmt::rfc2822::parse agreed with chrono::DateTime::parse_from_rfc2822 on 14 of 14 forms. Those covered GMT, UT, EST, PDT, Z and military zones, a missing weekday, two-digit years, missing seconds, a wrong weekday (refused by both), extra spaces, lowercase and a (UTC) comment.
  • Stored OAuth tokens. expires_at is RFC 3339 UTC either way.
  • make rs-check rs-check-drift rs-consumer-check passes locally: lint, tests, docs, cargo deny (advisories ok with an empty ignore list) for both workspaces, generated code up to date, and the consumer build with and without default features.

cargo semver-checks will flag the break; the breaking label is on.


Summary by cubic

Replaces the deprecated chrono crate with jiff 1.x in the Rust SDK, and drops the cargo-deny ignore for RUSTSEC-2026-0543. The wire format is unchanged — instants stay RFC 3339 and dates stay YYYY-MM-DD — so stored OAuth tokens read back as before, and no generated code changes. This is a breaking release; MIGRATING.md has the before-and-after table.

Migration

  • DateTime is jiff::Timestamp, Date wraps jiff::civil::Date, and the crate re-exports hey_sdk::jiff.
  • Date::from_datetime_in takes a jiff::tz::TimeZone, and Date::at_midnight_utc returns Option<DateTime>, None at the calendar's ends.
  • Weekdays are spelled out: Weekday::Monday instead of Weekday::Mon.
  • Date still parses only %Y-%m-%d, Date::default() stays 1970-01-01, and add_months/add_years keep Go's AddDate rollover.
  • Date now prints through the same %Y-%m-%d it reads, so dates before year 0 still round-trip.