#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

#42 in Date and time

Download history 35/week @ 2020-11-06 41/week @ 2020-11-13 38/week @ 2020-11-20 41/week @ 2020-11-27 56/week @ 2020-12-04 41/week @ 2020-12-11 40/week @ 2020-12-18 7/week @ 2020-12-25 30/week @ 2021-01-01 77/week @ 2021-01-08 30/week @ 2021-01-15 26/week @ 2021-01-22 23/week @ 2021-01-29 61/week @ 2021-02-05 67/week @ 2021-02-12 30/week @ 2021-02-19

139 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