mirror of
https://github.com/bspeice/dtparse
synced 2024-12-21 20:08:10 -05:00
commit
e9c994a755
18
src/lib.rs
18
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;
|
||||
@ -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)
|
||||
}
|
||||
|
@ -1,4 +1,3 @@
|
||||
mod fuzzing;
|
||||
mod pycompat_parser;
|
||||
mod pycompat_tokenizer;
|
||||
mod tz;
|
||||
|
@ -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());
|
||||
}
|
Loading…
Reference in New Issue
Block a user