Crate humantime_fmt

Crate humantime_fmt 

Source
Expand description

§humantime_fmt

A lightweight Rust crate to convert SystemTime values into human-friendly relative time strings like “just now”, “yesterday”, or “in 3 days”.

§Features

  • Works with past and future times relative to now
  • Granular output: seconds, minutes, hours, yesterday, days, last week, weeks

§Example

use humantime_fmt::format_relative;
use std::time::{SystemTime, Duration};

let now = SystemTime::now();
let past = now - Duration::from_secs(90);
let future = now + Duration::from_secs(3600);

assert_eq!(format_relative(past), "1 minute ago");
assert_eq!(format_relative(future), "in 1 hour");

Functions§

format_relative
Formats a SystemTime into a human-readable relative time string.