From 673d5b600e2e0b65eb7c26b2060dc48db7c1a41e Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Fri, 9 Jun 2023 10:15:23 +0200 Subject: [PATCH] rename from humantime_to_duration to parse_datetime --- Cargo.lock | 16 ++++++++-------- Cargo.toml | 4 ++-- README.md | 14 +++++++------- fuzz/Cargo.lock | 18 +++++++++--------- fuzz/Cargo.toml | 2 +- fuzz/fuzz_targets/from_str.rs | 2 +- fuzz/fuzz_targets/parse_datetime_from_str.rs | 2 +- src/lib.rs | 6 +++--- src/parse_datetime.rs | 2 +- tests/simple.rs | 2 +- 10 files changed, 34 insertions(+), 34 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 30d32c6..cbf9f8d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -68,14 +68,6 @@ version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa" -[[package]] -name = "humantime_to_duration" -version = "0.3.1" -dependencies = [ - "chrono", - "regex", -] - [[package]] name = "iana-time-zone" version = "0.1.56" @@ -141,6 +133,14 @@ version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" +[[package]] +name = "parse_datetime" +version = "0.3.1" +dependencies = [ + "chrono", + "regex", +] + [[package]] name = "proc-macro2" version = "1.0.59" diff --git a/Cargo.toml b/Cargo.toml index a527bb2..7612569 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,10 +1,10 @@ [package] -name = "humantime_to_duration" +name = "parse_datetime" description = " parsing human-readable relative time strings and converting them to a Duration" version = "0.3.1" edition = "2021" license = "MIT" -repository = "https://github.com/uutils/humantime_to_duration" +repository = "https://github.com/uutils/parse_datetime" readme = "README.md" [dependencies] diff --git a/README.md b/README.md index 2680073..04d2447 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ -# humantime_to_duration +# parse_datetime -[![Crates.io](https://img.shields.io/crates/v/humantime_to_duration.svg)](https://crates.io/crates/humantime_to_duration) -[![License](http://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/uutils/humantime_to_duration/blob/main/LICENSE) -[![CodeCov](https://codecov.io/gh/uutils/humantime_to_duration/branch/main/graph/badge.svg)](https://codecov.io/gh/uutils/humantime_to_duration) +[![Crates.io](https://img.shields.io/crates/v/parse_datetime.svg)](https://crates.io/crates/parse_datetime) +[![License](http://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/uutils/parse_datetime/blob/main/LICENSE) +[![CodeCov](https://codecov.io/gh/uutils/parse_datetime/branch/main/graph/badge.svg)](https://codecov.io/gh/uutils/parse_datetime) A Rust crate for parsing human-readable relative time strings and converting them to a `Duration`, or parsing human-readable datetime strings and converting them to a `DateTime`. @@ -20,12 +20,12 @@ Add this to your `Cargo.toml`: ```toml [dependencies] -humantime_to_duration = "0.3.0" +parse_datetime = "0.3.0" ``` Then, import the crate and use the `from_str` and `from_str_at_date` functions: ```rs -use humantime_to_duration::{from_str, from_str_at_date}; +use parse_datetime::{from_str, from_str_at_date}; use chrono::Duration; let duration = from_str("+3 days"); @@ -41,7 +41,7 @@ assert_eq!( For DateTime parsing, import the `parse_datetime` module: ```rs -use humantime_to_duration::parse_datetime::from_str; +use parse_datetime::parse_datetime::from_str; use chrono::{Local, TimeZone}; let dt = from_str("2021-02-14 06:37:47"); diff --git a/fuzz/Cargo.lock b/fuzz/Cargo.lock index f6ed013..9785c58 100644 --- a/fuzz/Cargo.lock +++ b/fuzz/Cargo.lock @@ -85,8 +85,8 @@ name = "fuzz_from_str" version = "0.1.0" dependencies = [ "chrono", - "humantime_to_duration", "libfuzzer-sys", + "parse_datetime", "rand", "regex", ] @@ -102,14 +102,6 @@ dependencies = [ "wasi 0.11.0+wasi-snapshot-preview1", ] -[[package]] -name = "humantime_to_duration" -version = "0.3.1" -dependencies = [ - "chrono", - "regex", -] - [[package]] name = "iana-time-zone" version = "0.1.56" @@ -195,6 +187,14 @@ version = "1.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3" +[[package]] +name = "parse_datetime" +version = "0.3.1" +dependencies = [ + "chrono", + "regex", +] + [[package]] name = "ppv-lite86" version = "0.2.17" diff --git a/fuzz/Cargo.toml b/fuzz/Cargo.toml index daaff8d..7b705b2 100644 --- a/fuzz/Cargo.toml +++ b/fuzz/Cargo.toml @@ -12,7 +12,7 @@ libfuzzer-sys = "0.4" regex = "1.8.4" chrono = "0.4" -[dependencies.humantime_to_duration] +[dependencies.parse_datetime] path = "../" [[bin]] diff --git a/fuzz/fuzz_targets/from_str.rs b/fuzz/fuzz_targets/from_str.rs index 5dd52aa..63b55d1 100644 --- a/fuzz/fuzz_targets/from_str.rs +++ b/fuzz/fuzz_targets/from_str.rs @@ -4,5 +4,5 @@ use libfuzzer_sys::fuzz_target; fuzz_target!(|data: &[u8]| { let s = std::str::from_utf8(data).unwrap_or(""); - let _ = humantime_to_duration::from_str(s); + let _ = parse_datetime::from_str(s); }); diff --git a/fuzz/fuzz_targets/parse_datetime_from_str.rs b/fuzz/fuzz_targets/parse_datetime_from_str.rs index 2db587b..7d285e5 100644 --- a/fuzz/fuzz_targets/parse_datetime_from_str.rs +++ b/fuzz/fuzz_targets/parse_datetime_from_str.rs @@ -4,5 +4,5 @@ use libfuzzer_sys::fuzz_target; fuzz_target!(|data: &[u8]| { let s = std::str::from_utf8(data).unwrap_or(""); - let _ = humantime_to_duration::parse_datetime::from_str(s); + let _ = parse_datetime::parse_datetime::from_str(s); }); diff --git a/src/lib.rs b/src/lib.rs index 21a4b46..8a104da 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -50,7 +50,7 @@ impl From for ParseDurationError { /// /// ``` /// use chrono::Duration; -/// let duration = humantime_to_duration::from_str("+3 days"); +/// let duration = parse_datetime::from_str("+3 days"); /// assert_eq!(duration.unwrap(), Duration::days(3)); /// ``` /// @@ -85,7 +85,7 @@ impl From for ParseDurationError { /// /// ``` /// use chrono::Duration; -/// use humantime_to_duration::{from_str, ParseDurationError}; +/// use parse_datetime::{from_str, ParseDurationError}; /// /// assert_eq!(from_str("1 hour, 30 minutes").unwrap(), Duration::minutes(90)); /// assert_eq!(from_str("tomorrow").unwrap(), Duration::days(1)); @@ -112,7 +112,7 @@ pub fn from_str(s: &str) -> Result { /// /// ``` /// use chrono::{Duration, NaiveDate, Utc, Local}; -/// use humantime_to_duration::{from_str_at_date, ParseDurationError}; +/// use parse_datetime::{from_str_at_date, ParseDurationError}; /// let today = Local::now().date().naive_local(); /// let yesterday = today - Duration::days(1); /// assert_eq!( diff --git a/src/parse_datetime.rs b/src/parse_datetime.rs index fcf5fae..d6f5514 100644 --- a/src/parse_datetime.rs +++ b/src/parse_datetime.rs @@ -36,7 +36,7 @@ mod format { /// /// ``` /// use chrono::{DateTime, Utc, TimeZone}; -/// let time = humantime_to_duration::parse_datetime::from_str("2023-06-03 12:00:01Z"); +/// let time = parse_datetime::parse_datetime::from_str("2023-06-03 12:00:01Z"); /// assert_eq!(time.unwrap(), Utc.with_ymd_and_hms(2023, 06, 03, 12, 00, 01).unwrap()); /// ``` /// diff --git a/tests/simple.rs b/tests/simple.rs index 366f318..a538f9d 100644 --- a/tests/simple.rs +++ b/tests/simple.rs @@ -1,5 +1,5 @@ use chrono::{Duration, Utc}; -use humantime_to_duration::{from_str, from_str_at_date, ParseDurationError}; +use parse_datetime::{from_str, from_str_at_date, ParseDurationError}; #[test] fn test_invalid_input() {