#format-duration #time #duration #seconds #duration-string #format-time #date-format

compound_duration

Convert seconds to compound duration (week, days, hours, minutes, seconds)

7 stable releases

1.2.1 Apr 18, 2023
1.2.0 May 23, 2020
1.0.2 Nov 13, 2019
1.0.1 Oct 26, 2019
1.0.0 Jun 15, 2019

#177 in Date and time

Download history 125/week @ 2024-07-04 154/week @ 2024-07-11 125/week @ 2024-07-18 191/week @ 2024-07-25 112/week @ 2024-08-01 154/week @ 2024-08-08 140/week @ 2024-08-15 124/week @ 2024-08-22 106/week @ 2024-08-29 79/week @ 2024-09-05 100/week @ 2024-09-12 133/week @ 2024-09-19 108/week @ 2024-09-26 85/week @ 2024-10-03 69/week @ 2024-10-10 86/week @ 2024-10-17

387 downloads per month
Used in 8 crates (7 directly)

Custom license

12KB
213 lines

compound_duration

crates.io Build Status

Convert seconds to compound duration (week, days, hours, minutes, seconds)

input number output string
7259 2h59s
86400 1d
6000000 9w6d10h40m
4294967295 7101w3d6h28m15s

format_dhms or format_wdhms, example:

use compound_duration::format_dhms;
use std::time::Instant;

fn main() {
    let now = Instant::now();
    // do something ...
    println!("{}", format_dhms(now.elapsed().as_secs()));
}

If need nanoseconds use format_ns:

use compound_duration::format_ns;
use std::time::Instant;

fn main() {
    let now = Instant::now();
    // do something ...
    println!("{}", format_ns(now.elapsed().as_nanos()));
}

lib.rs:

Convert seconds to compound duration (week, days, hours, minutes, seconds)

No runtime deps