hn.today

Jiff 1.0: A datetime library for Rust

burntsushi.net436 points95 comments
Screenshot of Jiff 1.0: A datetime library for Rust

Jiff 1.0 is a Rust datetime library designed to keep the complexity of date and time handling inside the library rather than leaving users to manage it themselves. Its release formalizes a long-term stability commitment: because Jiff is already used in widely adopted Rust projects and may appear in other libraries’ public APIs, incompatible changes will be made only for significant defects. The library’s central design choice is to make time zones prominent, helping users avoid common errors around daylight saving time and the difference between clock time and an unambiguous instant.

The API is explained through a layered model: civil dates and times represent calendar values without a location; a timestamp represents an instant; a time zone maps between instants and local clock values; and a zoned datetime combines those pieces. This distinction matters when local times are missing during spring clock changes or occur twice during autumn changes. Jiff resolves such ambiguity with a compatible default and offers explicit choices, including selecting the earlier or later occurrence or returning an error. The broader API tour covers parsing and formatting, duration representations, date arithmetic and rounding, calendar support, and guidance on choosing among datetime types. The release is aimed at Rust programmers seeking convenient datetime handling with safer, more explicit treatment of time zones.

Read on burntsushi.net95 comments on Hacker News

Summary generated by AI from the linked article. hn.today is not affiliated with Hacker News or Y Combinator.

More in Programming

Solid 2.0

Solid 2.0

Solid 2.0 is now stable, five years after version 1.0, with a smaller API and diagnostics designed for AI agents. Its reactive graph now handles asynchronous computations, while built-in server functions support RPC calls and persistent Server-Sent Events connections. (solidjs.com)

The daily digest

Today's best Hacker News stories, summarized and screenshotted, one email a day.