basic-human-duration

Crates.iobasic-human-duration
lib.rsbasic-human-duration
version0.2.0
sourcesrc
created_at2020-12-10 23:45:43.353074
updated_at2023-04-09 19:15:44.260836
descriptionSimple human formatting of chrono::Duration
homepage
repositoryhttps://github.com/SmailBarkouch/chrono-human-duration
max_upload_size
id321678
size5,863
Smail Barkouch (smailbarkouch)

documentation

README

basic-human-duration

A very small crate to format durations for humans.

In comparison to the original repo...

  • this supports months
  • this adjusts what is considered "just now" (before it was <60 minutes, now it is <60 seconds)
  • has other minor adjustments

Example

use basic_human_duration::ChronoHumanDuration;
use chrono::Duration;

let d = Duration::weeks(2) + Duration::days(3);
assert_eq!(d.format_human().to_string(), "2 weeks ago");
let d = Duration::seconds(20);
assert_eq!(d.format_human().to_string(), "just now");
Commit count: 14

cargo fmt