fasttime
fasttime is a small UTC-focused date/time library for Rust. It is built
around Ben Joffe's constant-time 64-bit days→date algorithm and offers a simple,
no_std-friendly API for calendar math, parsing, and formatting. The crate
only depends on core by default and enables a handful of conveniences (such as
DateTime::now_utc()) when the optional std feature is on.
Features
- Works in
no_stdenvironments; opt intostdwhen you need wall-clock time. Date,Time,DateTime,Duration,UtcOffset, andOffsetDateTimetypes with ISO/RFC 3339 styleDisplayimplementations.- Parsing helpers for the common textual formats used in logs and APIs.
- Fixed-offset RFC 3339 timestamps with nanosecond precision.
- Simple arithmetic helpers: add days, add durations, compute differences, and fetch ordinals or weekdays without extra allocations.
Installation
[]
= "0.1"
Disable the default std feature when targeting bare-metal or embedded
environments:
[]
= { = "0.1", = false }
Example
use ;
Benchmarks
cargo bench --bench unix_timestamp runs a Criterion benchmark that compares
fasttime::DateTime::from_unix_timestamp with time::OffsetDateTime::from_unix_timestamp_nanos.
Example output
from_unix_timestamp/fasttime::DateTime
time: [9.0027 µs 9.0169 µs 9.0311 µs]
Found 8 outliers among 100 measurements (8.00%)
3 (3.00%) low mild
4 (4.00%) high mild
1 (1.00%) high severe
from_unix_timestamp/time::OffsetDateTime
time: [11.872 µs 11.963 µs 12.077 µs]
Found 11 outliers among 100 measurements (11.00%)
3 (3.00%) high mild
8 (8.00%) high severe
Development
- Format and lint the crate with your preferred Rust tooling (
cargo fmt,cargo clippy). - Run the tests with
cargo test.
License
Licensed under the Apache License, Version 2.0 (see Cargo.toml metadata).