Urgent.News

What's breaking now, across thousands of outlets.

Tech

A datetime library for Rust

Jiff is a datetime library for Rust that simplifies and streamlines datetime handling for Rust programmers. It addresses common issues related to daylight saving time and provides a robust API for working with various time concepts. Jiff's API is well-documented, making it easy to understand and use. The library is already widely adopted in the Rust ecosystem and has proven its reliability in production projects.

Jiff's core functionality revolves around converting between system time (Unix time) and human-conceived time (Gregorian calendar and time zones). The library aims to encapsulate complexity and make it difficult for users to misuse datetime handling. Jiff's datetime types can be thought of like an onion, with multiple layers. The core types include Timezone and ZonedDateTime.

A ZonedDateTime can be created from either a civil datetime and a Timezone or a timestamp and a Timezone. Timezone offsets represent the adjustment needed to convert UTC time to civil time. A time zone is a geographic region where civil clocks agree and provide consistent mappings between civil datetime and offsets. Ambiguities can arise when civil datetime transitions occur, such as during daylight saving time adjustments.

Jiff resolves these ambiguities using a "fold" concept. The library provides a straightforward API for working with datetime concepts, making it an ideal choice for Rust programmers needing reliable and efficient datetime handling.

Written by urgent.news from Lobsters's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at burntsushi.net →

More in Tech

More from Sunday 15 November →