Merge pull request #20 from bspeice/timezone

Remove timezone handling
pull/24/head
bspeice 2019-11-30 08:41:11 -05:00 committed by GitHub
commit e9c994a755
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 35 deletions

View File

@ -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;
@ -959,7 +956,7 @@ impl Parser {
fn build_tzaware(
&self,
dt: &NaiveDateTime,
_dt: &NaiveDateTime,
res: &ParsingResult,
tzinfos: &HashMap<String, i32>,
) -> ParseResult<Option<FixedOffset>> {
@ -976,16 +973,9 @@ impl Parser {
Ok(Some(FixedOffset::east(
*tzinfos.get(res.tzname.as_ref().unwrap()).unwrap(),
)))
} else if res.tzname.is_some() {
let tzname = res.tzname.as_ref().unwrap();
let tz: Result<Tz, String> = 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)
}
} else if let Some(tzname) = res.tzname.as_ref() {
println!("tzname {} identified but not understood.", tzname);
Ok(None)
} else {
Err(ParseError::TimezoneUnsupported)
}

View File

@ -1,4 +1,3 @@
mod fuzzing;
mod pycompat_parser;
mod pycompat_tokenizer;
mod tz;

View File

@ -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());
}