Jiff 1.0: Putting Rust's Date and Time Rules in the Types
An appointment at 9:00 tomorrow and an event that happened at 9:00 yesterday look alike on a calendar. In software, they can demand different information. The first may be a wall-clock intention in a particular city; the second is a point on the global timeline. Treat both as an unqualified timestamp and the mistakes appear at daylight saving transitions, in recurring schedules, or when an event crosses a time-zone boundary.
Jiff 1.0 gives Rust programmers separate types for those meanings. Its release also comes with a substantial compatibility commitment: barring a serious API defect, maintainer Andrew Gallant intends to keep the 1.0 API stable indefinitely. That matters because date and time values often escape into library interfaces and stored data. Cargo, uv, Nushell, Jujutsu, Starship, and other projects already use Jiff in production.
The design is easier to understand by following a meeting invitation from a local clock reading to a precise instant, then asking what happens when the clock moves.
A clock reading is not an instant
Jiff starts with civil values: civil::Date is a Gregorian calendar date, civil::Time is a clock time, and civil::DateTime combines them. None says where it happened. “November 1 at 01:30” cannot identify a unique moment without more information.
Timestamp identifies a precise instant using Unix time. It does not imply a local display. TimeZone supplies the rules that map between a timestamp and a civil date and time in a region. ZonedDateTime brings those pieces together: an instant, its local clock reading, and the region’s rules.
This distinction guides storage and APIs. A server event recorded in UTC can be a Timestamp. A user’s selected appointment in America/New_York is better represented as a ZonedDateTime when its geographic context matters. A time entered in a date picker, before the user chooses a zone, is a civil::DateTime. If you only need to measure how long a function took, use Rust’s monotonic std::time::Instant instead; wall clocks can be adjusted.
For example, Jiff can construct a date and attach a zone:
use jiff::civil;
let local = civil::date(2026, 11, 17).at(9, 0, 0, 0);
let meeting = local.in_tz("Asia/Singapore")?;
println!("{}", meeting.timestamp());
The IANA identifier is more useful than saving only +08:00. An offset describes one moment’s difference from UTC; a time zone contains the historical and future rules needed for other moments. That difference becomes essential when schedules span seasonal clock changes.
The hour that happens twice
On November 1, 2026, New York moves from daylight saving time to standard time. At the change, the 01:00 hour repeats. The wall-clock reading 2026-11-01T01:30 maps to two instants: once at UTC−04:00 and once at UTC−05:00. A plain civil::DateTime has no way to choose between them.
Jiff’s default compatible policy chooses the first occurrence in this fold. Its lower-level time-zone API lets an application choose the earlier or later occurrence, or reject ambiguity and ask for a more precise input. That last option is valuable for transactions or appointments where silently selecting an hour would be surprising.
The reverse problem is a gap. When New York advances from 02:00 to 03:00 on March 8, 2026, 02:30 never occurs locally. Jiff’s compatible policy moves to the later valid side of the gap. Its explicit strategies can instead choose the earlier side or reject the input. The correct business rule depends on the application: a casual calendar reminder may move forward, while a payroll cutoff may need an error and human review.
use jiff::{civil::date, tz::TimeZone};
let zone = TimeZone::get("America/New_York")?;
let local = date(2026, 11, 1).at(1, 30, 0, 0);
let first = zone.to_ambiguous_zoned_datetime(local).earlier()?;
let second = zone.to_ambiguous_zoned_datetime(local).later()?;
assert_ne!(first.timestamp(), second.timestamp());
These policies make the ambiguity visible where an application can decide what it means. The zone database supplies the rules; the application owns the choice when a local time is not unique.
Calendar time and elapsed time answer different questions
Jiff has two duration families. A Span holds calendar units such as years, months, weeks, and days alongside hours and smaller units. A SignedDuration is an exact signed quantity of physical time, using units no larger than hours. Rust’s std::time::Duration is also accepted by many Jiff arithmetic operations, but it cannot be negative.
Suppose a product promises “same local time tomorrow.” Adding one calendar day to a zoned datetime expresses that promise. Adding exactly 24 hours expresses a different promise: the same elapsed interval. Around a daylight saving transition, the two results can differ by an hour. Neither rule is inherently right; the product wording determines which one to use.
Month arithmetic has the same shape. January 31 plus one month cannot retain day 31 in February. Jiff constrains the result to the last valid day of that month. The release tour demonstrates that May 31 plus one month becomes June 30, while adding two months reaches July 31. This is calendar arithmetic, not a fixed number of seconds.
use jiff::{civil, ToSpan};
let start = civil::date(2025, 1, 31);
let next = start.checked_add(1.month())?;
assert_eq!(next, civil::date(2025, 2, 28));
checked_add returns an error if a calculation goes outside the supported range. The + operator is concise for known-safe values, but can panic on overflow. Fallible constructors are similarly useful for input: civil::Date::new(2025, 2, 29) returns an error, while civil::date(...) is a convenient const constructor for dates known to be valid in source code.
Jiff also includes the operations that ordinary calendar products need after construction. first_of_month, last_of_year, yesterday, and tomorrow can answer common boundary questions without hand-written month lengths. A with() builder changes several fields before validation, so moving February 29 to March 31 can set the month and day together rather than failing halfway through. Weekday methods can find the second Thursday ahead or the last Sunday of a month. A series iterator can produce repeated dates from a starting value and a span, such as eight weekly occurrences.
Those operations remain zone aware on ZonedDateTime. In New York’s autumn clock change, tomorrow() from a particular afternoon can preserve the same local clock time while 25 physical hours pass. If that destination falls into a gap or fold, the compatible ambiguity policy applies. An application that needs a different rule can perform the calendar operation on the civil value and then resolve it through the zone explicitly.
Differences also carry units. Two civil dates can be compared in calendar days; two instants can be compared in physical time. A Span retains its component fields, so 2.hours() and 120.minutes() are not the same fieldwise representation even when they cover the same interval. Jiff provides compare, total, and rounding APIs to ask a more precise question. Converting a span into months or balancing hours into days needs a relative date, because months have varying lengths and zoned days can have 23 or 25 hours.
That preservation of fields is useful beyond mathematics. A film runtime usually reads better as 90 minutes, while a meeting invitation reads better as one hour and 30 minutes. Both can be built with the ToSpan convenience trait, and SpanRound can rebalance the fields into a chosen largest unit. Rebalancing 90.minutes() into hours produces 1h 30m; asking for minutes as the largest unit reverses it. When the smallest unit is set, the same API can perform actual rounding, with a selectable mode and increment. For user-provided unit counts, try_hours and similar fallible builders avoid a panic on values outside a span’s range.
Parsing should preserve the meaning
Jiff’s standard FromStr and Display implementations make ordinary values easy to exchange. A Timestamp uses RFC 3339, such as 2026-11-17T01:00:00Z. A ZonedDateTime uses the extended form in RFC 9557, which can retain an IANA name: 2026-11-17T09:00:00+08:00[Asia/Singapore]. That bracketed name matters: an offset alone cannot explain the zone’s rules for next month’s meeting.
Civil dates and times use ISO 8601 forms. Jiff parses and prints Span and SignedDuration in ISO 8601 duration form by default, such as PT5H30M. It also accepts a friendlier form such as 2h 30m. The friendly form can retain the original unit fields when that distinction matters. For example, 2,000 milliseconds prints as two seconds in ISO form, but a friendly representation can preserve 2000ms.
This is a meaningful serialization choice. An ISO duration string is widely understood, but its normalized form may erase whether the original value was written in seconds or milliseconds. If the field choice itself is part of an API contract or user interface, print the friendly form with format!("{span:#}") or Span::to_friendly(). If interoperable exchange matters more, use the ISO representation. Both forms can be parsed into Jiff’s duration types, subject to each type’s unit limits: a SignedDuration cannot accept calendar months or days.
For nonstandard inputs, Jiff provides strptime and strftime style routines and lower-level format modules, including RFC 2822. Parsing an ambiguous zoned value can be configured with a disambiguation policy. Locale-sensitive display and non-Gregorian calendars live in the separate ICU4X integration via jiff-icu; Jiff itself uses the proleptic Gregorian calendar. That keeps its core calendar model focused while allowing applications to reach for localization when they need it.
The lower-level parsers are useful when input is only partially specified or arrives in another protocol. BrokenDownTime, for example, exposes which date and time components were actually present instead of silently inventing a complete instant. The RFC 2822 parser can work from bytes, which is useful for mail headers. For a zoned string with a repeated local clock time, a configurable Temporal-style parser can use earlier, later, compatible, or reject behavior. A display string for an end user is a separate problem: jiff-icu converts Jiff values for ICU4X locale formatting, including language-specific date order and time-zone names.
Rounding still needs context
Rounding a timestamp to a half-hour is straightforward. Rounding a zoned datetime to a day must respect the actual length and boundaries of that local day. The release tour gives a New York example in which a day is 25 hours long after clocks fall back; its halfway point is 12 hours and 30 minutes, not noon after a fixed 24-hour interval. Jiff uses the zone rules when rounding.
The same idea appears when balancing a Span. If an application has 2,756 hours and wants months, days, and hours, it must supply a date from which to count. Starting from a civil date and starting from a zoned date in Rome yield different hour remainders across a spring transition. Without that reference, a conversion to calendar units would be guessing.
What the 1.0 release changes for adopters
The milestone is about API stability as much as features. Jiff was already used by prominent Rust tools before 1.0; its maintainer now intends the crate to be safe to expose in public library APIs without routine incompatible version churn. The largest source migration from 0.2 is the rename from Zoned to ZonedDateTime, with related method names changing as well. Version 1.0 also raises the minimum supported Rust version to 1.85. The project changelog lists the remaining breaking changes.
Adoption still begins with the question your application asks. Use Timestamp for a precise event, civil::DateTime for an unresolved clock reading, and ZonedDateTime when a location’s rules are part of the meaning. Choose a calendar Span for “next month at this local time,” a physical duration for “after exactly this many seconds,” and an explicit ambiguity policy whenever a repeated or missing hour has business consequences. With those distinctions made in the types, the difficult parts of datetime handling become decisions you can see and review.
Sources: Jiff 1.0 release tour, Jiff design rationale, Jiff repository, and RFC 9557.