Skip to content

Commit ff0e728

Browse files
committed
Fixes issues with timezone
This pr should fix the issue with the timezones #36. Now all tests are passing.
1 parent ff0f99b commit ff0e728

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// Expose parse_datetime
55
pub mod parse_datetime;
66

7-
use chrono::{Duration, Local, NaiveDate, Utc};
7+
use chrono::{Duration, Local, NaiveDate};
88
use regex::{Error as RegexError, Regex};
99
use std::error::Error;
1010
use std::fmt::{self, Display};
@@ -92,7 +92,7 @@ impl From<RegexError> for ParseDurationError {
9292
/// assert!(matches!(from_str("invalid"), Err(ParseDurationError::InvalidInput)));
9393
/// ```
9494
pub fn from_str(s: &str) -> Result<Duration, ParseDurationError> {
95-
from_str_at_date(Utc::now().date_naive(), s)
95+
from_str_at_date(Local::now().date_naive(), s)
9696
}
9797

9898
/// Parses a duration string and returns a `Duration` instance, with the duration

tests/simple.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use chrono::{Duration, Utc};
1+
use chrono::{Duration, Local, Utc};
22
use parse_datetime::{from_str, from_str_at_date, ParseDurationError};
33

44
#[test]
@@ -128,7 +128,7 @@ fn test_display_should_fail() {
128128

129129
#[test]
130130
fn test_from_str_at_date_day() {
131-
let today = Utc::now().date_naive();
131+
let today = Local::now().date_naive();
132132
let yesterday = today - Duration::days(1);
133133
assert_eq!(
134134
from_str_at_date(yesterday, "2 days").unwrap(),

0 commit comments

Comments
 (0)