Skip to content

Commit

Permalink
version: bump to 0.1.6 (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
waltzofpearls authored Oct 10, 2021
1 parent 1eb59dd commit 9ebc134
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 9 deletions.
4 changes: 2 additions & 2 deletions 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 belt/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "belt"
version = "0.1.5"
version = "0.1.6"
authors = ["Rollie Ma <rollie@rollie.dev>"]
edition = "2018"
publish = false
Expand Down
2 changes: 1 addition & 1 deletion dateparser/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "dateparser"
version = "0.1.5"
version = "0.1.6"
authors = ["Rollie Ma <rollie@rollie.dev>"]
description = "Parse dates in string formats that are commonly used"
readme = "README.md"
Expand Down
32 changes: 27 additions & 5 deletions dateparser/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Add to your `Cargo.toml`:

```toml
[dependencies]
dateparser = "0.1.5"
dateparser = "0.1.6"
```

And then use `dateparser` in your code:
Expand Down Expand Up @@ -57,7 +57,7 @@ Convert returned `DateTime<Utc>` to pacific time zone datetime with `chrono-tz`:
```toml
[dependencies]
chrono-tz = "0.5.3"
dateparser = "0.1.5"
dateparser = "0.1.6"
```

```rust
Expand All @@ -82,13 +82,35 @@ use std::error::Error;

fn main() -> Result<(), Box<dyn Error>> {
let parsed_in_local = parse_with_timezone("6:15pm", &Local)?;
println!("{:#?}" parsed_in_local);
println!("{:#?}", parsed_in_local);

let parsed_in_utc = parse_with_timezone("6:15pm", &Utc)?;
println!("{:#?}" parsed_in_utc);
println!("{:#?}", parsed_in_utc);

let parsed_in_pacific = parse_with_timezone("6:15pm", &Pacific)?;
println!("{:#?}" parsed_in_pacific);
println!("{:#?}", parsed_in_pacific);

Ok(())
}
```

Parse with a custom timezone offset and default time when those are not given in datetime string.
By default, `parse` and `parse_with_timezone` uses `Utc::now().time()` as `default_time`.

```rust
use dateparser::parse_with;
use chrono::{
offset::{Local, Utc},
naive::NaiveTime,
};
use std::error::Error;

fn main() -> Result<(), Box<dyn Error>> {
let parsed_in_local = parse_with("2021-10-09", &Local, NaiveTime::from_hms(0, 0, 0))?;
println!("{:#?}", parsed_in_local);

let parsed_in_utc = parse_with("2021-10-09", &Utc, NaiveTime::from_hms(0, 0, 0))?;
println!("{:#?}", parsed_in_utc);

Ok(())
}
Expand Down
File renamed without changes.
16 changes: 16 additions & 0 deletions dateparser/examples/parse_with.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
use chrono::{
naive::NaiveTime,
offset::{Local, Utc},
};
use dateparser::parse_with;
use std::error::Error;

fn main() -> Result<(), Box<dyn Error>> {
let parsed_in_local = parse_with("2021-10-09", &Local, NaiveTime::from_hms(0, 0, 0))?;
println!("{:#?}", parsed_in_local);

let parsed_in_utc = parse_with("2021-10-09", &Utc, NaiveTime::from_hms(0, 0, 0))?;
println!("{:#?}", parsed_in_utc);

Ok(())
}
17 changes: 17 additions & 0 deletions dateparser/examples/parse_with_timezone.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
use chrono::offset::{Local, Utc};
use chrono_tz::US::Pacific;
use dateparser::parse_with_timezone;
use std::error::Error;

fn main() -> Result<(), Box<dyn Error>> {
let parsed_in_local = parse_with_timezone("6:15pm", &Local)?;
println!("{:#?}", parsed_in_local);

let parsed_in_utc = parse_with_timezone("6:15pm", &Utc)?;
println!("{:#?}", parsed_in_utc);

let parsed_in_pacific = parse_with_timezone("6:15pm", &Pacific)?;
println!("{:#?}", parsed_in_pacific);

Ok(())
}

0 comments on commit 9ebc134

Please sign in to comment.