#time #format #duration #compound #seconds

compound_duration

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

6 stable releases

1.2.0 May 23, 2020
1.1.0 May 11, 2020
1.0.2 Nov 13, 2019
1.0.1 Oct 26, 2019
1.0.0 Jun 15, 2019

#52 in Date and time

Download history 24/week @ 2021-02-20 23/week @ 2021-02-27 47/week @ 2021-03-06 33/week @ 2021-03-13 67/week @ 2021-03-20 93/week @ 2021-03-27 116/week @ 2021-04-03 55/week @ 2021-04-10 50/week @ 2021-04-17 48/week @ 2021-04-24 21/week @ 2021-05-01 116/week @ 2021-05-08 69/week @ 2021-05-15 111/week @ 2021-05-22 41/week @ 2021-05-29 41/week @ 2021-06-05

257 downloads per month
Used in 4 crates

Custom license

11KB
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() as usize));
}

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() as usize));
}

No runtime deps