Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -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]
Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -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`.

Expand All @@ -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");
Expand All @@ -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");
Expand Down
18 changes: 9 additions & 9 deletions fuzz/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion fuzz/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ libfuzzer-sys = "0.4"
regex = "1.8.4"
chrono = "0.4"

[dependencies.humantime_to_duration]
[dependencies.parse_datetime]
path = "../"

[[bin]]
Expand Down
2 changes: 1 addition & 1 deletion fuzz/fuzz_targets/from_str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
2 changes: 1 addition & 1 deletion fuzz/fuzz_targets/parse_datetime_from_str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
6 changes: 3 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
/// ```
///
Expand Down Expand Up @@ -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));
Expand All @@ -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!(
Expand Down
2 changes: 1 addition & 1 deletion src/parse_datetime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
/// ```
///
Expand Down
2 changes: 1 addition & 1 deletion tests/simple.rs
Original file line number Diff line number Diff line change
@@ -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() {
Expand Down