feat: add humantime-demo
This commit is contained in:
@@ -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
16
__time/humantime-demo/Cargo.lock
generated
Normal 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",
|
||||
]
|
||||
9
__time/humantime-demo/Cargo.toml
Normal file
9
__time/humantime-demo/Cargo.toml
Normal 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"
|
||||
11
__time/humantime-demo/src/main.rs
Normal file
11
__time/humantime-demo/src/main.rs
Normal 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);
|
||||
}
|
||||
Reference in New Issue
Block a user