Expand description
§nanotime
A minimal, zero-dependency time utility crate for Rust CLI applications.
nanotime provides nanosecond-precision timestamps, human-readable formatting,
relative time strings, and a simple elapsed-time stopwatch — all without pulling
in heavy datetime libraries.
§Quick start
use nanotime::{NanoTime, Elapsed};
// Current local time
let now = NanoTime::now();
println!("{}", now.datetime()); // "2026-02-23 14:30:05.042"
// From a Unix epoch
let t = NanoTime::from_epoch(1_000_000_000);
println!("{}", t.date()); // "2001-09-09"
// Relative time
let earlier = NanoTime::from_epoch(1_000_000_000);
let later = NanoTime::from_epoch(1_000_003_600);
println!("{}", earlier.relative_to(&later)); // "1h ago"
// Stopwatch
let timer = Elapsed::start();
// ... do work ...
println!("took {}", timer); // "42ms"