You've already forked parse_datetime
mirror of
https://github.com/uutils/parse_datetime.git
synced 2026-06-10 16:13:15 -07:00
rename from humantime_to_duration to parse_datetime
This commit is contained in:
Generated
+8
-8
@@ -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"
|
||||
|
||||
+2
-2
@@ -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]
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
# humantime_to_duration
|
||||
# parse_datetime
|
||||
|
||||
[](https://crates.io/crates/humantime_to_duration)
|
||||
[](https://github.com/uutils/humantime_to_duration/blob/main/LICENSE)
|
||||
[](https://codecov.io/gh/uutils/humantime_to_duration)
|
||||
[](https://crates.io/crates/parse_datetime)
|
||||
[](https://github.com/uutils/parse_datetime/blob/main/LICENSE)
|
||||
[](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");
|
||||
|
||||
Generated
+9
-9
@@ -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"
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@ libfuzzer-sys = "0.4"
|
||||
regex = "1.8.4"
|
||||
chrono = "0.4"
|
||||
|
||||
[dependencies.humantime_to_duration]
|
||||
[dependencies.parse_datetime]
|
||||
path = "../"
|
||||
|
||||
[[bin]]
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
|
||||
+3
-3
@@ -50,7 +50,7 @@ impl From<RegexError> 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<RegexError> 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<Duration, ParseDurationError> {
|
||||
///
|
||||
/// ```
|
||||
/// 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!(
|
||||
|
||||
@@ -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());
|
||||
/// ```
|
||||
///
|
||||
|
||||
+1
-1
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user