1
0
mirror of https://github.com/bspeice/dtparse synced 2024-12-21 20:08:10 -05:00
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:
bors[bot] 2020-06-11 18:18:24 +00:00 committed by GitHub
commit 899cd88280
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 32 additions and 3 deletions

View File

@ -81,7 +81,7 @@ tests = {
'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',
'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'
],
'test_fuzzy_tzinfo': [

View File

@ -347,7 +347,9 @@ impl ParserInfo {
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.tzoffset = Some(0);
} else if res.tzoffset != Some(0)
@ -885,7 +887,7 @@ impl Parser {
&& tzname.is_none()
&& tzoffset.is_none()
&& token.len() <= 5
&& all_ascii_upper
&& (all_ascii_upper || self.info.utczone.contains_key(token))
}
#[allow(clippy::unnecessary_unwrap)]

View File

@ -3348,6 +3348,33 @@ fn test_parse_ignoretz6() {
#[test]
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 pdt = PyDateTime {
year: 1995,