feat: add humantime-demo

This commit is contained in:
2023-01-17 23:32:05 +08:00
parent 570b578596
commit 3a98d7da3f
4 changed files with 38 additions and 1 deletions

View File

@@ -204,6 +204,7 @@ Project or files:
│   └── term
├── __time
│   ├── chrono
│   ├── humantime-demo
│   └── iron
├── __translate
│   └── retranslate
@@ -260,6 +261,6 @@ Project or files:
├── vec.rs
└── while.rs
229 directories, 38 files
230 directories, 39 files
```

16
__time/humantime-demo/Cargo.lock generated Normal file
View File

@@ -0,0 +1,16 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "humantime"
version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4"
[[package]]
name = "humantime-demo"
version = "0.1.0"
dependencies = [
"humantime",
]

View File

@@ -0,0 +1,9 @@
[package]
name = "humantime-demo"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
humantime = "2.1.0"

View File

@@ -0,0 +1,11 @@
use std::time::{Duration, SystemTime};
fn main() {
let formatted = humantime::format_duration(
SystemTime::now().duration_since(SystemTime::UNIX_EPOCH).unwrap()
);
println!("{}", formatted);
let formatted = humantime::format_duration(Duration::from_millis(1000000));
println!("{}", formatted);
}