mirror of
https://github.com/bspeice/dtparse
synced 2024-12-22 04:18:09 -05:00
Merge #27
27: Add fixes for dateutil/dateutil#822 r=bspeice a=bspeice Fixes #16 Co-authored-by: Bradlee Speice <bradlee@speice.io>
This commit is contained in:
commit
899cd88280
@ -81,7 +81,7 @@ tests = {
|
|||||||
'Thu Sep 25 10:36:28 BRST 2003', '1996.07.10 AD at 15:08:56 PDT',
|
'Thu Sep 25 10:36:28 BRST 2003', '1996.07.10 AD at 15:08:56 PDT',
|
||||||
'Tuesday, April 12, 1952 AD 3:30:42pm PST',
|
'Tuesday, April 12, 1952 AD 3:30:42pm PST',
|
||||||
'November 5, 1994, 8:15:30 am EST', '1994-11-05T08:15:30-05:00',
|
'November 5, 1994, 8:15:30 am EST', '1994-11-05T08:15:30-05:00',
|
||||||
'1994-11-05T08:15:30Z', '1976-07-04T00:01:02Z',
|
'1994-11-05T08:15:30Z', '1976-07-04T00:01:02Z', '1986-07-05T08:15:30z',
|
||||||
'Tue Apr 4 00:22:12 PDT 1995'
|
'Tue Apr 4 00:22:12 PDT 1995'
|
||||||
],
|
],
|
||||||
'test_fuzzy_tzinfo': [
|
'test_fuzzy_tzinfo': [
|
||||||
|
@ -347,7 +347,9 @@ impl ParserInfo {
|
|||||||
res.year = Some(self.convertyear(y, res.century_specified))
|
res.year = Some(self.convertyear(y, res.century_specified))
|
||||||
};
|
};
|
||||||
|
|
||||||
if res.tzoffset == Some(0) && res.tzname.is_none() || res.tzname == Some("Z".to_owned()) {
|
if (res.tzoffset == Some(0) && res.tzname.is_none())
|
||||||
|
|| (res.tzname == Some("Z".to_owned()) || res.tzname == Some("z".to_owned()))
|
||||||
|
{
|
||||||
res.tzname = Some("UTC".to_owned());
|
res.tzname = Some("UTC".to_owned());
|
||||||
res.tzoffset = Some(0);
|
res.tzoffset = Some(0);
|
||||||
} else if res.tzoffset != Some(0)
|
} else if res.tzoffset != Some(0)
|
||||||
@ -885,7 +887,7 @@ impl Parser {
|
|||||||
&& tzname.is_none()
|
&& tzname.is_none()
|
||||||
&& tzoffset.is_none()
|
&& tzoffset.is_none()
|
||||||
&& token.len() <= 5
|
&& token.len() <= 5
|
||||||
&& all_ascii_upper
|
&& (all_ascii_upper || self.info.utczone.contains_key(token))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(clippy::unnecessary_unwrap)]
|
#[allow(clippy::unnecessary_unwrap)]
|
||||||
|
@ -3348,6 +3348,33 @@ fn test_parse_ignoretz6() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_parse_ignoretz7() {
|
fn test_parse_ignoretz7() {
|
||||||
|
let info = ParserInfo::default();
|
||||||
|
let pdt = PyDateTime {
|
||||||
|
year: 1986,
|
||||||
|
month: 7,
|
||||||
|
day: 5,
|
||||||
|
hour: 8,
|
||||||
|
minute: 15,
|
||||||
|
second: 30,
|
||||||
|
micros: 0,
|
||||||
|
tzo: None,
|
||||||
|
};
|
||||||
|
parse_and_assert(
|
||||||
|
pdt,
|
||||||
|
info,
|
||||||
|
"1986-07-05T08:15:30z",
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
None,
|
||||||
|
true,
|
||||||
|
&HashMap::new(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_parse_ignoretz8() {
|
||||||
let info = ParserInfo::default();
|
let info = ParserInfo::default();
|
||||||
let pdt = PyDateTime {
|
let pdt = PyDateTime {
|
||||||
year: 1995,
|
year: 1995,
|
||||||
|
Loading…
Reference in New Issue
Block a user