Jiff 1.0: A datetime library for Rust burntsushi.net · 229 points · 49 comments ...

@best30

Jiff 1.0: A datetime library for Rust burntsushi.net · 229 points · 49 comments · HN thread

TL;DR Andrew Gallant (burntsushi) announces Jiff 1.0, a Rust datetime library that puts time zone handling at the center of its API and commits to a stable 1.0 API. The post walks through core types (civil dates, Timestamp, TimeZone, ZonedDateTime, Span, SignedDuration), DST disambiguation, parsing/formatting (RFC 3339, RFC 9557, ISO 8601, a custom friendly duration format, strptime/strftime), ICU4X integration, and arithmetic and rounding. Jiff is heavily inspired by JavaScript's Temporal proposal.

  • Jiff 1.0 is declared stable; the author commits to not making semver-incompatible changes lightly, since Jiff is meant to appear in other libraries' public APIs.
  • Jiff is already used by uv, Cargo, Starship, fd, Nushell, mise, Jujutsu, uutils/coreutils, and underpins a Temporal implementation in AWS LLRT.
  • Time zone handling is built into the API: ZonedDateTime pairs a Timestamp with a TimeZone, and ambiguous DST times are resolved by explicit strategies (compatible, earlier, later, reject).
  • Span keeps calendar and physical units distinct (2 hours is not equal to 120 minutes as values), while SignedDuration covers physical time only; Span arithmetic needs a relative date for calendar units.
  • Jiff adds a lossless 'friendly' duration format because ISO 8601 cannot represent every Span (e.g. 2000ms round-trips as 2s).
  • Only the Gregorian calendar is supported natively; other calendars and locale-aware formatting go through ICU4X via jiff-icu. Range is limited to +/-9999 years and only the Unix time scale is supported.

Discussion The thread is mostly appreciative and celebratory, with commenters praising burntsushi's work and the library's design. A large side discussion grew out of the chrono comparison: a former chrono maintainer described burnout and stalled API improvements, and others noted chrono is now semi-deprecated and that Jiff is easy to switch to. Another thread debated whether Rust's standard library should include a datetime API, with replies pointing to the value of iterating in third-party crates, the risks of stdlib lock-in, and Java's java.time as a counterexample. Lighter threads joked about the 'gif' pronunciation.

  • Jiff is a strong, well-designed successor to chrono and time (many): Commenters praise Jiff's API and documentation and say they are switching from chrono. Several note it is already easy to adopt and expect it to become the default in the Rust ecosystem.
  • Chrono's API has been stuck and is now deprecated (some): A former chrono maintainer says the API was hard to improve because stability was prized over change, and commenters point to chrono's deprecation issue. Others push back that chrono has been comfortable to use for years.
  • Rust should have a datetime library in the standard library (some): Some argue a standard datetime library would reduce supply-chain risk and make the default easy. Replies counter that stdlib inclusion locks in mistakes, and that Rust's model of iterating in crates is deliberate; Java's java.time is cited as a success story either way.
  • Jiff is not suited to every domain (a few): A commenter doing solar-system orbit simulations needs TAI-like or other time scales, which Jiff does not support; the author recommends hifitime instead.
  • Jokes and pronunciation banter (a few): Several comments play with the author's note that Jiff is pronounced like 'gif' with a soft g, joking about hard-g or the GIF acronym.

Links from the comments

#rust #datetime #timezones #libraries #temporal