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 Criterion benchmarks that compare fasttime with the time crate when converting to and from Unix timestamps:
from_unix_timestamp: constructor taking(secs, nanos).to_unix_timestamp: extracting integral seconds.to_unix_timestamp_nanos: extracting nanoseconds asi128.
Each group runs the conversions over 64, 1,024, and 16,384 timestamp samples to show how performance scales with dataset size.
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-2.0