jflib-datetime
Calendar time for JFLib, without the standard library and without a line of
unsafe code: timestamps, calendar dates, ISO weeks, RFC 3339 text, time zones with daylight
saving time, and cron schedules. It has no clock of its own and only computes, so it gives the
same answers on every machine.
What it does
A Timestamp is a point in time, seconds and nanoseconds since 1970 in UTC. A Civil is a
calendar date and wall time without a zone (Civil::from_unix and to_unix convert), and free
functions answer the calendar questions: leap years, the days of a month, the weekday, the ISO 8601
week of a date and the Monday of a week. rfc3339 and parse_rfc3339 write and read the timestamps of logs and
protocols, format_date_time, format_duration and format_relative the texts people read (in
German or English).
Zone knows the zones of the IANA time zone database by name, each with its current rule for
daylight saving time, maps Windows' time zone names to them, and also takes a POSIX TZ string or a
TZif file such as /etc/localtime. It turns a timestamp into local time and back. Going back is
the hard direction, and from_local says so honestly: a wall time is Single, Ambiguous in the
hour the clocks repeat, or falls into the Gap when they jump forward.
Cron reads five-field cron expressions, with month and weekday names and shortcuts such as
@daily, and finds the next runs in a zone. A run that falls into a skipped hour happens right
after the jump, one in a repeated hour happens once. describe puts a schedule into words.
use ;
use ;
let now = from_nanos;
let berlin = by_name.unwrap_or_else;
let stamp = rfc3339; // "2026-11-13T09:30:00.123Z"
let shown = format_date_time; // "2026-11-13 10:30"
if let Ok = parse
A zone describes its offsets from its last rule change on: times before that change are computed with today's rule. That suits schedules, logs and displays of the present, not historical records.
How to get it
Like all of JFLib, the crate comes through the one dependency
jflib, as jflib::datetime. All of JFLib's crates share one
version and are released together. It runs on every platform JFLib supports.
What's new in 0.2.2
Nothing in this crate. It is released again as 0.2.2 only because all of JFLib's crates move together. The changelog says the same.
Documentation
- JFLib's guide: how an app is written
- API reference: every public
item of
datetime, also on docs.rs
License
MIT or Apache-2.0, at your choice. The table that maps Windows' time zone names to IANA zones comes from the Unicode CLDR and is also under the Unicode License v3.