2 unstable releases

0.2.0 Apr 9, 2023
0.1.2 Dec 10, 2020

#362 in Date and time

Download history 1/week @ 2024-09-07 20/week @ 2024-09-21 26/week @ 2024-09-28 8/week @ 2024-10-05 10/week @ 2024-10-12 1/week @ 2024-10-19 1/week @ 2024-10-26 13/week @ 2024-11-02 2/week @ 2024-11-09 5/week @ 2024-11-16 13/week @ 2024-11-23 23/week @ 2024-11-30 12/week @ 2024-12-07 4/week @ 2024-12-14

53 downloads per month
Used in lb-rs

Apache-2.0/MIT

6KB
109 lines

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");

Dependencies

~755KB
~14K SLoC