chrono-human-duration-modified

Crates.iochrono-human-duration-modified
lib.rschrono-human-duration-modified
version0.1.2
sourcesrc
created_at2020-12-10 23:21:33.168874
updated_at2020-12-10 23:21:33.168874
descriptionSimple human formatting of chrono::Duration
homepage
repositoryhttps://github.com/SmailBarkouch/chrono-human-duration
max_upload_size
id321663
size12,335
Smail Barkouch (smailbarkouch)

documentation

README

chrono-human-duration

Very small crate for format durations for humans.

In comparison to the original repo...

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

Example

use chrono_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