From d5e0a5d46a9a64ce3576d486c7a7b0533dabf563 Mon Sep 17 00:00:00 2001 From: Bradlee Speice Date: Fri, 29 Nov 2019 16:49:29 -0500 Subject: [PATCH 1/3] Remove timezone handling There are too many issues in chrono-tz to make it worth supporting. --- src/lib.rs | 11 ++--------- src/tests/mod.rs | 1 - src/tests/tz.rs | 20 -------------------- 3 files changed, 2 insertions(+), 30 deletions(-) delete mode 100644 src/tests/tz.rs diff --git a/src/lib.rs b/src/lib.rs index 3e8af54..f783e61 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -977,15 +977,8 @@ impl Parser { *tzinfos.get(res.tzname.as_ref().unwrap()).unwrap(), ))) } else if res.tzname.is_some() { - let tzname = res.tzname.as_ref().unwrap(); - let tz: Result = tzname.parse(); - if tz.is_ok() { - let offset = tz.unwrap().offset_from_local_datetime(dt).unwrap().fix(); - Ok(Some(offset)) - } else { - println!("tzname {} identified but not understood ({}). Ignoring for the time being, but behavior is subject to change.", tzname, tz.unwrap_err()); - Ok(None) - } + println!("tzname {} identified but not understood.", tzname); + Ok(None) } else { Err(ParseError::TimezoneUnsupported) } diff --git a/src/tests/mod.rs b/src/tests/mod.rs index 9ea7f0f..1776124 100644 --- a/src/tests/mod.rs +++ b/src/tests/mod.rs @@ -1,4 +1,3 @@ mod fuzzing; mod pycompat_parser; mod pycompat_tokenizer; -mod tz; diff --git a/src/tests/tz.rs b/src/tests/tz.rs deleted file mode 100644 index f71f1ee..0000000 --- a/src/tests/tz.rs +++ /dev/null @@ -1,20 +0,0 @@ -use parse; - -#[test] -fn est() { - // Issue originally reported in https://github.com/bspeice/dtparse/issues/18 - let dt = parse("Fri, 21 Aug 2015 18:37:44 EST"); - - assert!(dt.is_ok()); - assert!(dt.unwrap().1.is_some()); -} - -#[test] -fn cest() { - // Issue originally reported in https://github.com/bspeice/dtparse/issues/18 - let dt = parse("Fri, 21 Aug 2015 18:37:44 CEST"); - - assert!(dt.is_ok()); - // TODO: Fix - // assert!(dt.unwrap().1.is_some()); -} From d7ff381d7faaded70fe656187112b85c1bca67df Mon Sep 17 00:00:00 2001 From: Bradlee Speice Date: Fri, 29 Nov 2019 17:58:40 -0500 Subject: [PATCH 2/3] Bugfix --- src/lib.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index f783e61..bab9a80 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -84,10 +84,7 @@ use chrono::Local; use chrono::NaiveDate; use chrono::NaiveDateTime; use chrono::NaiveTime; -use chrono::Offset; -use chrono::TimeZone; use chrono::Timelike; -use chrono_tz::Tz; use num_traits::cast::ToPrimitive; use rust_decimal::Decimal; use rust_decimal::Error as DecimalError; @@ -976,7 +973,7 @@ impl Parser { Ok(Some(FixedOffset::east( *tzinfos.get(res.tzname.as_ref().unwrap()).unwrap(), ))) - } else if res.tzname.is_some() { + } else if let Some(tzname) = res.tzname.as_ref() { println!("tzname {} identified but not understood.", tzname); Ok(None) } else { From d6fc72459e8bbc6b72ca1feda6a31e431e742fcc Mon Sep 17 00:00:00 2001 From: Bradlee Speice Date: Fri, 29 Nov 2019 18:19:13 -0500 Subject: [PATCH 3/3] Mark unused --- src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index bab9a80..cafca07 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -956,7 +956,7 @@ impl Parser { fn build_tzaware( &self, - dt: &NaiveDateTime, + _dt: &NaiveDateTime, res: &ParsingResult, tzinfos: &HashMap, ) -> ParseResult> {