mirror of
https://github.com/bspeice/dtparse
synced 2024-11-13 17:38:09 -05:00
We're so close to passing!
This commit is contained in:
parent
a00156780d
commit
921b449c1c
12
src/lib.rs
12
src/lib.rs
@ -776,7 +776,7 @@ impl Parser {
|
|||||||
let naive = self.build_naive(&res, &default_ts);
|
let naive = self.build_naive(&res, &default_ts);
|
||||||
|
|
||||||
if !ignoretz {
|
if !ignoretz {
|
||||||
let offset = self.build_tzaware(&naive, &res, &default_ts)?;
|
let offset = self.build_tzaware(&naive, &res, tzinfos)?;
|
||||||
Ok((naive, offset, tokens))
|
Ok((naive, offset, tokens))
|
||||||
} else {
|
} else {
|
||||||
Ok((naive, None, tokens))
|
Ok((naive, None, tokens))
|
||||||
@ -955,7 +955,7 @@ impl Parser {
|
|||||||
tzoffset: Option<i32>,
|
tzoffset: Option<i32>,
|
||||||
token: &str,
|
token: &str,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
let all_ascii_upper = token == token.to_ascii_uppercase();
|
let all_ascii_upper = token.chars().all(|c| 65u8 as char <= c && c <= 90u8 as char);
|
||||||
return hour.is_some() && tzname.is_none() && tzoffset.is_none() && token.len() <= 5
|
return hour.is_some() && tzname.is_none() && tzoffset.is_none() && token.len() <= 5
|
||||||
&& all_ascii_upper;
|
&& all_ascii_upper;
|
||||||
}
|
}
|
||||||
@ -1007,7 +1007,7 @@ impl Parser {
|
|||||||
&self,
|
&self,
|
||||||
dt: &NaiveDateTime,
|
dt: &NaiveDateTime,
|
||||||
res: &ParsingResult,
|
res: &ParsingResult,
|
||||||
default: &NaiveDateTime,
|
tzinfos: HashMap<String, i32>,
|
||||||
) -> ParseResult<Option<FixedOffset>> {
|
) -> ParseResult<Option<FixedOffset>> {
|
||||||
// TODO: Actual timezone support
|
// TODO: Actual timezone support
|
||||||
if let Some(offset) = res.tzoffset {
|
if let Some(offset) = res.tzoffset {
|
||||||
@ -1017,6 +1017,12 @@ impl Parser {
|
|||||||
|| res.tzname == Some("-".to_owned()) || res.tzname == None)
|
|| res.tzname == Some("-".to_owned()) || res.tzname == None)
|
||||||
{
|
{
|
||||||
Ok(None)
|
Ok(None)
|
||||||
|
} else if res.tzname.is_some() && tzinfos.contains_key(res.tzname.as_ref().unwrap()) {
|
||||||
|
Ok(Some(FixedOffset::east(tzinfos.get(res.tzname.as_ref().unwrap()).unwrap().clone())))
|
||||||
|
} else if res.tzname.is_some() {
|
||||||
|
// TODO: Dateutil issues a warning/deprecation notice here. Should we force the issue?
|
||||||
|
println!("tzname {} identified but not understood. Ignoring for the time being, but behavior is subject to change.", res.tzname.as_ref().unwrap());
|
||||||
|
Ok(None)
|
||||||
} else {
|
} else {
|
||||||
Err(ParseError::TimezoneUnsupported)
|
Err(ParseError::TimezoneUnsupported)
|
||||||
}
|
}
|
||||||
|
@ -302,9 +302,9 @@ fn test_dateutil_compat() {
|
|||||||
// TODO: Uncomment tests once timezone support is in
|
// TODO: Uncomment tests once timezone support is in
|
||||||
|
|
||||||
// testDateCommandFormat
|
// testDateCommandFormat
|
||||||
// test_parse!(py, parser, datetime, "Thu Sep 25 10:36:28 BRST 2003");
|
test_parse!(py, parser, datetime, "Thu Sep 25 10:36:28 BRST 2003");
|
||||||
// testDateCommandFormatReversed
|
// testDateCommandFormatReversed
|
||||||
// test_parse!(py, parser, datetime, "2003 10:36:28 BRST 25 Sep Thu");
|
test_parse!(py, parser, datetime, "2003 10:36:28 BRST 25 Sep Thu");
|
||||||
|
|
||||||
// testDateCommandFormatStrip1
|
// testDateCommandFormatStrip1
|
||||||
test_parse!(py, parser, datetime, "Thu Sep 25 10:36:28 2003");
|
test_parse!(py, parser, datetime, "Thu Sep 25 10:36:28 2003");
|
||||||
@ -330,10 +330,9 @@ fn test_dateutil_compat() {
|
|||||||
test_parse!(py, parser, datetime, "2003");
|
test_parse!(py, parser, datetime, "2003");
|
||||||
// testDateRCommandFormat
|
// testDateRCommandFormat
|
||||||
test_parse!(py, parser, datetime, "Thu, 25 Sep 2003 10:49:41 -0300");
|
test_parse!(py, parser, datetime, "Thu, 25 Sep 2003 10:49:41 -0300");
|
||||||
// testISOFormat
|
// testISOFormat - Needs some debug work on the python side
|
||||||
// test_parse!(py, parser, datetime, "2003-09-25T10:49:41.5-03:00");
|
// test_parse!(py, parser, datetime, "2003-09-25T10:49:41.5-03:00");
|
||||||
// TODO: tzoffset not properly recognized
|
// testISOFormatStrip1 - Needs same as above
|
||||||
// testISOFormatStrip1
|
|
||||||
// test_parse!(py, parser, datetime, "2003-09-25T10:49:41-03:00");
|
// test_parse!(py, parser, datetime, "2003-09-25T10:49:41-03:00");
|
||||||
// testISOFormatStrip2
|
// testISOFormatStrip2
|
||||||
test_parse!(py, parser, datetime, "2003-09-25T10:49:41");
|
test_parse!(py, parser, datetime, "2003-09-25T10:49:41");
|
||||||
@ -499,22 +498,19 @@ fn test_dateutil_compat() {
|
|||||||
|
|
||||||
// testRandomFormat1
|
// testRandomFormat1
|
||||||
test_parse!(py, parser, datetime, "Wed, July 10, '96");
|
test_parse!(py, parser, datetime, "Wed, July 10, '96");
|
||||||
// TODO: TZ support (PDT is unrecognized)
|
|
||||||
// testRandomFormat2
|
// testRandomFormat2
|
||||||
// test_parse_ignoretz!(py, parser, datetime, "1996.07.10 AD at 15:08:56 PDT");
|
test_parse_ignoretz!(py, parser, datetime, "1996.07.10 AD at 15:08:56 PDT");
|
||||||
|
|
||||||
// testRandomFormat3
|
// testRandomFormat3
|
||||||
test_parse!(py, parser, datetime, "1996.July.10 AD 12:08 PM");
|
test_parse!(py, parser, datetime, "1996.July.10 AD 12:08 PM");
|
||||||
|
|
||||||
// TODO: UnrecognizedToken("PST")
|
|
||||||
// testRandomFormat4
|
// testRandomFormat4
|
||||||
// test_parse_ignoretz!(py, parser, datetime, "Tuesday, April 12, 1952 AD 3:30:42pm PST");
|
test_parse_ignoretz!(py, parser, datetime, "Tuesday, April 12, 1952 AD 3:30:42pm PST");
|
||||||
// TODO: UnrecognizedToken("EST")
|
|
||||||
// testRandomFormat5
|
// testRandomFormat5
|
||||||
// test_parse_ignoretz!(py, parser, datetime, "November 5, 1994, 8:15:30 am EST");
|
test_parse_ignoretz!(py, parser, datetime, "November 5, 1994, 8:15:30 am EST");
|
||||||
// TODO: Parse error - finds hour 5 instead of 8
|
// TODO: Parse error - finds hour 5 instead of 8
|
||||||
// testRandomFormat6
|
// testRandomFormat6
|
||||||
// test_parse_ignoretz!(py, parser, datetime, "1994-11-05T08:15:30-05:00");
|
test_parse_ignoretz!(py, parser, datetime, "1994-11-05T08:15:30-05:00");
|
||||||
// testRandomFormat7
|
// testRandomFormat7
|
||||||
test_parse_ignoretz!(py, parser, datetime, "1994-11-05T08:15:30Z");
|
test_parse_ignoretz!(py, parser, datetime, "1994-11-05T08:15:30Z");
|
||||||
// testRandomFormat8
|
// testRandomFormat8
|
||||||
@ -533,22 +529,22 @@ fn test_dateutil_compat() {
|
|||||||
test_parse!(py, parser, datetime, "12h 01m02s am");
|
test_parse!(py, parser, datetime, "12h 01m02s am");
|
||||||
// testRandomFormat15; NB: testRandomFormat16 is exactly the same
|
// testRandomFormat15; NB: testRandomFormat16 is exactly the same
|
||||||
test_parse!(py, parser, datetime, "0:01:02 on July 4, 1976");
|
test_parse!(py, parser, datetime, "0:01:02 on July 4, 1976");
|
||||||
// testRandomFormat17 - Needs ignoretz
|
// testRandomFormat17
|
||||||
test_parse_ignoretz!(py, parser, datetime, "1976-07-04T00:01:02Z");
|
test_parse_ignoretz!(py, parser, datetime, "1976-07-04T00:01:02Z");
|
||||||
// testRandomFormat18
|
// testRandomFormat18
|
||||||
test_parse!(py, parser, datetime, "July 4, 1976 12:01:02 am");
|
test_parse!(py, parser, datetime, "July 4, 1976 12:01:02 am");
|
||||||
// testRandomFormat19
|
// testRandomFormat19
|
||||||
test_parse!(py, parser, datetime, "Mon Jan 2 04:24:27 1995");
|
test_parse!(py, parser, datetime, "Mon Jan 2 04:24:27 1995");
|
||||||
// testRandomFormat20 - Needs ignoretz
|
// testRandomFormat20
|
||||||
// test_parse_ignoretz!(py, parser, datetime, "Tue Apr 4 00:22:12 PDT 1995");
|
test_parse_ignoretz!(py, parser, datetime, "Tue Apr 4 00:22:12 PDT 1995");
|
||||||
// testRandomFormat21
|
// testRandomFormat21
|
||||||
test_parse!(py, parser, datetime, "04.04.95 00:22");
|
test_parse!(py, parser, datetime, "04.04.95 00:22");
|
||||||
// testRandomFormat22
|
// testRandomFormat22
|
||||||
test_parse!(py, parser, datetime, "Jan 1 1999 11:23:34.578");
|
test_parse!(py, parser, datetime, "Jan 1 1999 11:23:34.578");
|
||||||
// testRandomFormat23
|
// testRandomFormat23
|
||||||
test_parse!(py, parser, datetime, "950404 122212");
|
test_parse!(py, parser, datetime, "950404 122212");
|
||||||
// testRandomFormat24 - Needs ignoretz
|
// testRandomFormat24
|
||||||
// test_parse_ignoretz!(py, parser, datetime, "0:00 PM, PST");
|
test_parse_ignoretz!(py, parser, datetime, "0:00 PM, PST");
|
||||||
// testRandomFormat25
|
// testRandomFormat25
|
||||||
test_parse!(py, parser, datetime, "12:08 PM");
|
test_parse!(py, parser, datetime, "12:08 PM");
|
||||||
// testRandomFormat26
|
// testRandomFormat26
|
||||||
|
Loading…
Reference in New Issue
Block a user