From 3a98d7da3f21ee98b25933467cc36a897c055c19 Mon Sep 17 00:00:00 2001 From: Hatter Jiang Date: Tue, 17 Jan 2023 23:32:05 +0800 Subject: [PATCH] feat: add humantime-demo --- README.md | 3 ++- __time/humantime-demo/Cargo.lock | 16 ++++++++++++++++ __time/humantime-demo/Cargo.toml | 9 +++++++++ __time/humantime-demo/src/main.rs | 11 +++++++++++ 4 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 __time/humantime-demo/Cargo.lock create mode 100644 __time/humantime-demo/Cargo.toml create mode 100644 __time/humantime-demo/src/main.rs diff --git a/README.md b/README.md index 486fadd..6fcec52 100644 --- a/README.md +++ b/README.md @@ -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 ``` diff --git a/__time/humantime-demo/Cargo.lock b/__time/humantime-demo/Cargo.lock new file mode 100644 index 0000000..3cd0e82 --- /dev/null +++ b/__time/humantime-demo/Cargo.lock @@ -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", +] diff --git a/__time/humantime-demo/Cargo.toml b/__time/humantime-demo/Cargo.toml new file mode 100644 index 0000000..9ea1c6e --- /dev/null +++ b/__time/humantime-demo/Cargo.toml @@ -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" diff --git a/__time/humantime-demo/src/main.rs b/__time/humantime-demo/src/main.rs new file mode 100644 index 0000000..925419c --- /dev/null +++ b/__time/humantime-demo/src/main.rs @@ -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); +}