7 个稳定版本
| 1.2.1 | 2023年4月18日 |
|---|---|
| 1.2.0 | 2020年5月23日 |
| 1.0.2 | 2019年11月13日 |
| 1.0.1 | 2019年10月26日 |
| 1.0.0 | 2019年6月15日 |
#92 in 日期和时间
555 每月下载量
用于 8 个 crate (7 直接)
12KB
213 行
compound_duration
将秒转换为复合持续时间(周、天、小时、分钟、秒)
| 输入数字 | 输出字符串 |
|---|---|
| 7259 | 2h59s |
| 86400 | 1d |
| 6000000 | 9w6d10h40m |
| 4294967295 | 7101w3d6h28m15s |
format_dhms 或 format_wdhms,示例
use compound_duration::format_dhms;
use std::time::Instant;
fn main() {
let now = Instant::now();
// do something ...
println!("{}", format_dhms(now.elapsed().as_secs()));
}
如需使用纳秒,请使用 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:
将秒转换为复合持续时间(周、天、小时、分钟、秒)