From 317a854b9f51bc6f4a60d1b5b7f66bd9b0a1fa04 Mon Sep 17 00:00:00 2001 From: taichong Date: Tue, 16 Jul 2024 22:18:00 +0800 Subject: [PATCH] fix: invalid timezone should return err not panic --- src/lib.rs | 21 +- src/tests/fuzzing.rs | 27 +- src/tests/mod.rs | 12 +- src/tests/pycompat_parser.rs | 3365 ++++++++++++++++++++++++++-------- 4 files changed, 2678 insertions(+), 747 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 723148d..c2dfdb0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -715,7 +715,8 @@ impl Parser { ) -> ParseResult<(NaiveDateTime, Option, Option>)> { let default_date = default.unwrap_or(&Local::now().naive_local()).date(); - let default_ts = NaiveDateTime::new(default_date, NaiveTime::from_hms_opt(0, 0, 0).unwrap()); + let default_ts = + NaiveDateTime::new(default_date, NaiveTime::from_hms_opt(0, 0, 0).unwrap()); let (res, tokens) = self.parse_with_tokens(timestr, dayfirst, yearfirst, fuzzy, fuzzy_with_tokens)?; @@ -853,7 +854,12 @@ impl Parser { } else if i + 2 < len_l && l[i + 2] == ":" { // -03:00 hour_offset = Some(l[i + 1].parse::()?); - min_offset = Some(l[i + 3].parse::()?); + // if timezone is wrong format like "-03:" just return a Err, should not panic. + min_offset = if i + 3 > l.len() - 1 { + return Err(ParseError::TimezoneUnsupported); + } else { + Some(l[i + 3].parse::()?) + }; i += 2; } else if len_li <= 2 { // -[0]3 @@ -979,9 +985,9 @@ impl Parser { let hour = res.hour.unwrap_or(default.hour() as i32) as u32; let minute = res.minute.unwrap_or(default.minute() as i32) as u32; let second = res.second.unwrap_or(default.second() as i32) as u32; - let nanosecond = res - .nanosecond - .unwrap_or(default.timestamp_subsec_nanos() as i64) as u32; + let nanosecond = + res.nanosecond + .unwrap_or(default.and_utc().timestamp_subsec_nanos() as i64) as u32; let t = NaiveTime::from_hms_nano_opt(hour, minute, second, nanosecond).ok_or_else(|| { if hour >= 24 { @@ -1155,7 +1161,10 @@ impl Parser { idx += 1; } else { //let value = value.floor().to_i32().ok_or(Err(ParseError::InvalidNumeric())) - let value = value.floor().to_i32().ok_or_else(|| ParseError::InvalidNumeric(value_repr.to_owned()))?; + let value = value + .floor() + .to_i32() + .ok_or_else(|| ParseError::InvalidNumeric(value_repr.to_owned()))?; ymd.append(value, &value_repr, None)?; } diff --git a/src/tests/fuzzing.rs b/src/tests/fuzzing.rs index 55befea..3626911 100644 --- a/src/tests/fuzzing.rs +++ b/src/tests/fuzzing.rs @@ -1,5 +1,5 @@ -use base64::Engine; use base64::engine::general_purpose::STANDARD; +use base64::Engine; use chrono::NaiveDate; use std::collections::HashMap; use std::str; @@ -21,7 +21,10 @@ fn test_fuzz() { Err(ParseError::UnrecognizedFormat) ); - let default = NaiveDate::from_ymd_opt(2016, 6, 29).unwrap().and_hms_opt(0, 0, 0).unwrap(); + let default = NaiveDate::from_ymd_opt(2016, 6, 29) + .unwrap() + .and_hms_opt(0, 0, 0) + .unwrap(); let p = Parser::default(); let res = p.parse( "\x0D\x31", @@ -66,12 +69,20 @@ fn empty_string() { #[test] fn github_33() { - assert_eq!(parse("66:'"), Err(ParseError::InvalidNumeric("'".to_owned()))) + assert_eq!( + parse("66:'"), + Err(ParseError::InvalidNumeric("'".to_owned())) + ) } #[test] fn github_32() { - assert_eq!(parse("99999999999999999999999"), Err(ParseError::InvalidNumeric("99999999999999999999999".to_owned()))) + assert_eq!( + parse("99999999999999999999999"), + Err(ParseError::InvalidNumeric( + "99999999999999999999999".to_owned() + )) + ) } #[test] @@ -96,4 +107,10 @@ fn github_36() { let parse_str = str::from_utf8(&parse_vec).unwrap(); let parse_result = parse(parse_str); assert!(parse_result.is_err()); -} \ No newline at end of file +} + +#[test] +fn github_46() { + let parse_result = parse("2000-01-01 12:00:00+00:"); + assert!(parse_result.is_err()); +} diff --git a/src/tests/mod.rs b/src/tests/mod.rs index 6dc10bb..b2a4ef4 100644 --- a/src/tests/mod.rs +++ b/src/tests/mod.rs @@ -2,13 +2,19 @@ mod fuzzing; mod pycompat_parser; mod pycompat_tokenizer; -use chrono::NaiveDate; use crate::parse; +use chrono::NaiveDate; #[test] fn nanosecond_precision() { assert_eq!( parse("2008.12.29T08:09:10.123456789").unwrap(), - (NaiveDate::from_ymd_opt(2008, 12, 29).unwrap().and_hms_nano_opt(8, 9, 10, 123_456_789).unwrap(), None) + ( + NaiveDate::from_ymd_opt(2008, 12, 29) + .unwrap() + .and_hms_nano_opt(8, 9, 10, 123_456_789) + .unwrap(), + None + ) ) -} \ No newline at end of file +} diff --git a/src/tests/pycompat_parser.rs b/src/tests/pycompat_parser.rs index a6542a9..e586cf0 100644 --- a/src/tests/pycompat_parser.rs +++ b/src/tests/pycompat_parser.rs @@ -1,4 +1,3 @@ - //! This code has been generated by running the `build_pycompat.py` script //! in the repository root. Please do not edit it, as your edits will be destroyed //! upon re-running code generation. @@ -11,9 +10,9 @@ use chrono::NaiveDateTime; use chrono::Timelike; use std::collections::HashMap; +use parse; use Parser; use ParserInfo; -use parse; struct PyDateTime { year: i32, @@ -23,7 +22,7 @@ struct PyDateTime { minute: u32, second: u32, micros: u32, - tzo: Option + tzo: Option, } fn parse_and_assert( @@ -38,41 +37,80 @@ fn parse_and_assert( ignoretz: bool, tzinfos: &HashMap, ) { - let parser = Parser::new(info); - let rs_parsed = parser.parse( - s, - dayfirst, - yearfirst, - fuzzy, - fuzzy_with_tokens, - default, - ignoretz, - tzinfos).expect(&format!("Unable to parse date in Rust '{}'", s)); + let rs_parsed = parser + .parse( + s, + dayfirst, + yearfirst, + fuzzy, + fuzzy_with_tokens, + default, + ignoretz, + tzinfos, + ) + .expect(&format!("Unable to parse date in Rust '{}'", s)); assert_eq!(pdt.year, rs_parsed.0.year(), "Year mismatch for '{}'", s); assert_eq!(pdt.month, rs_parsed.0.month(), "Month mismatch for '{}'", s); assert_eq!(pdt.day, rs_parsed.0.day(), "Day mismatch for '{}'", s); assert_eq!(pdt.hour, rs_parsed.0.hour(), "Hour mismatch for '{}'", s); - assert_eq!(pdt.minute, rs_parsed.0.minute(), "Minute mismatch f'or' {}", s); - assert_eq!(pdt.second, rs_parsed.0.second(), "Second mismatch for '{}'", s); - assert_eq!(pdt.micros, rs_parsed.0.timestamp_subsec_micros(), "Microsecond mismatch for '{}'", s); - assert_eq!(pdt.tzo, rs_parsed.1.map(|u| u.local_minus_utc()), "Timezone Offset mismatch for '{}'", s); + assert_eq!( + pdt.minute, + rs_parsed.0.minute(), + "Minute mismatch f'or' {}", + s + ); + assert_eq!( + pdt.second, + rs_parsed.0.second(), + "Second mismatch for '{}'", + s + ); + assert_eq!( + pdt.micros, + rs_parsed.0.and_utc().timestamp_subsec_micros(), + "Microsecond mismatch for '{}'", + s + ); + assert_eq!( + pdt.tzo, + rs_parsed.1.map(|u| u.local_minus_utc()), + "Timezone Offset mismatch for '{}'", + s + ); } -fn parse_and_assert_simple( - pdt: PyDateTime, - s: &str, -) { +fn parse_and_assert_simple(pdt: PyDateTime, s: &str) { let rs_parsed = parse(s).expect(&format!("Unable to parse date in Rust '{}'", s)); assert_eq!(pdt.year, rs_parsed.0.year(), "Year mismatch for '{}'", s); assert_eq!(pdt.month, rs_parsed.0.month(), "Month mismatch for '{}'", s); assert_eq!(pdt.day, rs_parsed.0.day(), "Day mismatch for '{}'", s); assert_eq!(pdt.hour, rs_parsed.0.hour(), "Hour mismatch for '{}'", s); - assert_eq!(pdt.minute, rs_parsed.0.minute(), "Minute mismatch for '{}'", s); - assert_eq!(pdt.second, rs_parsed.0.second(), "Second mismatch for '{}'", s); - assert_eq!(pdt.micros, rs_parsed.0.timestamp_subsec_micros(), "Microsecond mismatch for '{}'", s); - assert_eq!(pdt.tzo, rs_parsed.1.map(|u| u.local_minus_utc()), "Timezone Offset mismatch for '{}'", s); + assert_eq!( + pdt.minute, + rs_parsed.0.minute(), + "Minute mismatch for '{}'", + s + ); + assert_eq!( + pdt.second, + rs_parsed.0.second(), + "Second mismatch for '{}'", + s + ); + assert_eq!( + pdt.micros, + rs_parsed.0.and_utc().timestamp_subsec_micros(), + "Microsecond mismatch for '{}'", + s + ); + assert_eq!( + pdt.tzo, + rs_parsed.1.map(|u| u.local_minus_utc()), + "Timezone Offset mismatch for '{}'", + s + ); } fn parse_fuzzy_and_assert( @@ -88,654 +126,1527 @@ fn parse_fuzzy_and_assert( ignoretz: bool, tzinfos: &HashMap, ) { - let parser = Parser::new(info); - let rs_parsed = parser.parse( - s, - dayfirst, - yearfirst, - fuzzy, - fuzzy_with_tokens, - default, - ignoretz, - tzinfos).expect(&format!("Unable to parse date in Rust '{}'", s)); + let rs_parsed = parser + .parse( + s, + dayfirst, + yearfirst, + fuzzy, + fuzzy_with_tokens, + default, + ignoretz, + tzinfos, + ) + .expect(&format!("Unable to parse date in Rust '{}'", s)); assert_eq!(pdt.year, rs_parsed.0.year(), "Year mismatch for '{}'", s); assert_eq!(pdt.month, rs_parsed.0.month(), "Month mismatch for '{}'", s); assert_eq!(pdt.day, rs_parsed.0.day(), "Day mismatch for '{}'", s); assert_eq!(pdt.hour, rs_parsed.0.hour(), "Hour mismatch for '{}'", s); - assert_eq!(pdt.minute, rs_parsed.0.minute(), "Minute mismatch f'or' {}", s); - assert_eq!(pdt.second, rs_parsed.0.second(), "Second mismatch for '{}'", s); - assert_eq!(pdt.micros, rs_parsed.0.timestamp_subsec_micros(), "Microsecond mismatch for '{}'", s); - assert_eq!(pdt.tzo, rs_parsed.1.map(|u| u.local_minus_utc()), "Timezone Offset mismatch for '{}'", s); + assert_eq!( + pdt.minute, + rs_parsed.0.minute(), + "Minute mismatch f'or' {}", + s + ); + assert_eq!( + pdt.second, + rs_parsed.0.second(), + "Second mismatch for '{}'", + s + ); + assert_eq!( + pdt.micros, + rs_parsed.0.and_utc().timestamp_subsec_nanos(), + "Microsecond mismatch for '{}'", + s + ); + assert_eq!( + pdt.tzo, + rs_parsed.1.map(|u| u.local_minus_utc()), + "Timezone Offset mismatch for '{}'", + s + ); assert_eq!(ptokens, rs_parsed.2, "Tokens mismatch for '{}'", s); } macro_rules! rs_tzinfo_map { - () => ({ + () => {{ let mut h = HashMap::new(); h.insert("BRST".to_owned(), -10800); h - }); + }}; } #[test] fn test_parse_default0() { let info = ParserInfo::default(); - let default_rsdate = &NaiveDate::from_ymd_opt(2003, 9, 25).unwrap().and_hms_opt(0, 0, 0).unwrap(); + let default_rsdate = &NaiveDate::from_ymd_opt(2003, 9, 25) + .unwrap() + .and_hms_opt(0, 0, 0) + .unwrap(); let pdt = PyDateTime { - year: 2003, month: 9, day: 25, - hour: 10, minute: 36, second: 28, - micros: 0, tzo: None + year: 2003, + month: 9, + day: 25, + hour: 10, + minute: 36, + second: 28, + micros: 0, + tzo: None, }; - parse_and_assert(pdt, info, "Thu Sep 25 10:36:28", None, None, false, false, - Some(default_rsdate), false, &HashMap::new()); + parse_and_assert( + pdt, + info, + "Thu Sep 25 10:36:28", + None, + None, + false, + false, + Some(default_rsdate), + false, + &HashMap::new(), + ); } #[test] fn test_parse_default1() { let info = ParserInfo::default(); - let default_rsdate = &NaiveDate::from_ymd_opt(2003, 9, 25).unwrap().and_hms_opt(0, 0, 0).unwrap(); + let default_rsdate = &NaiveDate::from_ymd_opt(2003, 9, 25) + .unwrap() + .and_hms_opt(0, 0, 0) + .unwrap(); let pdt = PyDateTime { - year: 2003, month: 9, day: 25, - hour: 10, minute: 36, second: 28, - micros: 0, tzo: None + year: 2003, + month: 9, + day: 25, + hour: 10, + minute: 36, + second: 28, + micros: 0, + tzo: None, }; - parse_and_assert(pdt, info, "Sep 10:36:28", None, None, false, false, - Some(default_rsdate), false, &HashMap::new()); + parse_and_assert( + pdt, + info, + "Sep 10:36:28", + None, + None, + false, + false, + Some(default_rsdate), + false, + &HashMap::new(), + ); } #[test] fn test_parse_default2() { let info = ParserInfo::default(); - let default_rsdate = &NaiveDate::from_ymd_opt(2003, 9, 25).unwrap().and_hms_opt(0, 0, 0).unwrap(); + let default_rsdate = &NaiveDate::from_ymd_opt(2003, 9, 25) + .unwrap() + .and_hms_opt(0, 0, 0) + .unwrap(); let pdt = PyDateTime { - year: 2003, month: 9, day: 25, - hour: 10, minute: 36, second: 28, - micros: 0, tzo: None + year: 2003, + month: 9, + day: 25, + hour: 10, + minute: 36, + second: 28, + micros: 0, + tzo: None, }; - parse_and_assert(pdt, info, "10:36:28", None, None, false, false, - Some(default_rsdate), false, &HashMap::new()); + parse_and_assert( + pdt, + info, + "10:36:28", + None, + None, + false, + false, + Some(default_rsdate), + false, + &HashMap::new(), + ); } #[test] fn test_parse_default3() { let info = ParserInfo::default(); - let default_rsdate = &NaiveDate::from_ymd_opt(2003, 9, 25).unwrap().and_hms_opt(0, 0, 0).unwrap(); + let default_rsdate = &NaiveDate::from_ymd_opt(2003, 9, 25) + .unwrap() + .and_hms_opt(0, 0, 0) + .unwrap(); let pdt = PyDateTime { - year: 2003, month: 9, day: 25, - hour: 10, minute: 36, second: 0, - micros: 0, tzo: None + year: 2003, + month: 9, + day: 25, + hour: 10, + minute: 36, + second: 0, + micros: 0, + tzo: None, }; - parse_and_assert(pdt, info, "10:36", None, None, false, false, - Some(default_rsdate), false, &HashMap::new()); + parse_and_assert( + pdt, + info, + "10:36", + None, + None, + false, + false, + Some(default_rsdate), + false, + &HashMap::new(), + ); } #[test] fn test_parse_default4() { let info = ParserInfo::default(); - let default_rsdate = &NaiveDate::from_ymd_opt(2003, 9, 25).unwrap().and_hms_opt(0, 0, 0).unwrap(); + let default_rsdate = &NaiveDate::from_ymd_opt(2003, 9, 25) + .unwrap() + .and_hms_opt(0, 0, 0) + .unwrap(); let pdt = PyDateTime { - year: 2003, month: 9, day: 25, - hour: 0, minute: 0, second: 0, - micros: 0, tzo: None + year: 2003, + month: 9, + day: 25, + hour: 0, + minute: 0, + second: 0, + micros: 0, + tzo: None, }; - parse_and_assert(pdt, info, "Sep 2003", None, None, false, false, - Some(default_rsdate), false, &HashMap::new()); + parse_and_assert( + pdt, + info, + "Sep 2003", + None, + None, + false, + false, + Some(default_rsdate), + false, + &HashMap::new(), + ); } #[test] fn test_parse_default5() { let info = ParserInfo::default(); - let default_rsdate = &NaiveDate::from_ymd_opt(2003, 9, 25).unwrap().and_hms_opt(0, 0, 0).unwrap(); + let default_rsdate = &NaiveDate::from_ymd_opt(2003, 9, 25) + .unwrap() + .and_hms_opt(0, 0, 0) + .unwrap(); let pdt = PyDateTime { - year: 2003, month: 9, day: 25, - hour: 0, minute: 0, second: 0, - micros: 0, tzo: None + year: 2003, + month: 9, + day: 25, + hour: 0, + minute: 0, + second: 0, + micros: 0, + tzo: None, }; - parse_and_assert(pdt, info, "Sep", None, None, false, false, - Some(default_rsdate), false, &HashMap::new()); + parse_and_assert( + pdt, + info, + "Sep", + None, + None, + false, + false, + Some(default_rsdate), + false, + &HashMap::new(), + ); } #[test] fn test_parse_default6() { let info = ParserInfo::default(); - let default_rsdate = &NaiveDate::from_ymd_opt(2003, 9, 25).unwrap().and_hms_opt(0, 0, 0).unwrap(); + let default_rsdate = &NaiveDate::from_ymd_opt(2003, 9, 25) + .unwrap() + .and_hms_opt(0, 0, 0) + .unwrap(); let pdt = PyDateTime { - year: 2003, month: 9, day: 25, - hour: 0, minute: 0, second: 0, - micros: 0, tzo: None + year: 2003, + month: 9, + day: 25, + hour: 0, + minute: 0, + second: 0, + micros: 0, + tzo: None, }; - parse_and_assert(pdt, info, "2003", None, None, false, false, - Some(default_rsdate), false, &HashMap::new()); + parse_and_assert( + pdt, + info, + "2003", + None, + None, + false, + false, + Some(default_rsdate), + false, + &HashMap::new(), + ); } #[test] fn test_parse_default7() { let info = ParserInfo::default(); - let default_rsdate = &NaiveDate::from_ymd_opt(2003, 9, 25).unwrap().and_hms_opt(0, 0, 0).unwrap(); + let default_rsdate = &NaiveDate::from_ymd_opt(2003, 9, 25) + .unwrap() + .and_hms_opt(0, 0, 0) + .unwrap(); let pdt = PyDateTime { - year: 2003, month: 9, day: 25, - hour: 10, minute: 36, second: 28, - micros: 500000, tzo: None + year: 2003, + month: 9, + day: 25, + hour: 10, + minute: 36, + second: 28, + micros: 500000, + tzo: None, }; - parse_and_assert(pdt, info, "10h36m28.5s", None, None, false, false, - Some(default_rsdate), false, &HashMap::new()); + parse_and_assert( + pdt, + info, + "10h36m28.5s", + None, + None, + false, + false, + Some(default_rsdate), + false, + &HashMap::new(), + ); } #[test] fn test_parse_default8() { let info = ParserInfo::default(); - let default_rsdate = &NaiveDate::from_ymd_opt(2003, 9, 25).unwrap().and_hms_opt(0, 0, 0).unwrap(); + let default_rsdate = &NaiveDate::from_ymd_opt(2003, 9, 25) + .unwrap() + .and_hms_opt(0, 0, 0) + .unwrap(); let pdt = PyDateTime { - year: 2003, month: 9, day: 25, - hour: 10, minute: 36, second: 28, - micros: 0, tzo: None + year: 2003, + month: 9, + day: 25, + hour: 10, + minute: 36, + second: 28, + micros: 0, + tzo: None, }; - parse_and_assert(pdt, info, "10h36m28s", None, None, false, false, - Some(default_rsdate), false, &HashMap::new()); + parse_and_assert( + pdt, + info, + "10h36m28s", + None, + None, + false, + false, + Some(default_rsdate), + false, + &HashMap::new(), + ); } #[test] fn test_parse_default9() { let info = ParserInfo::default(); - let default_rsdate = &NaiveDate::from_ymd_opt(2003, 9, 25).unwrap().and_hms_opt(0, 0, 0).unwrap(); + let default_rsdate = &NaiveDate::from_ymd_opt(2003, 9, 25) + .unwrap() + .and_hms_opt(0, 0, 0) + .unwrap(); let pdt = PyDateTime { - year: 2003, month: 9, day: 25, - hour: 10, minute: 36, second: 0, - micros: 0, tzo: None + year: 2003, + month: 9, + day: 25, + hour: 10, + minute: 36, + second: 0, + micros: 0, + tzo: None, }; - parse_and_assert(pdt, info, "10h36m", None, None, false, false, - Some(default_rsdate), false, &HashMap::new()); + parse_and_assert( + pdt, + info, + "10h36m", + None, + None, + false, + false, + Some(default_rsdate), + false, + &HashMap::new(), + ); } #[test] fn test_parse_default10() { let info = ParserInfo::default(); - let default_rsdate = &NaiveDate::from_ymd_opt(2003, 9, 25).unwrap().and_hms_opt(0, 0, 0).unwrap(); + let default_rsdate = &NaiveDate::from_ymd_opt(2003, 9, 25) + .unwrap() + .and_hms_opt(0, 0, 0) + .unwrap(); let pdt = PyDateTime { - year: 2003, month: 9, day: 25, - hour: 10, minute: 0, second: 0, - micros: 0, tzo: None + year: 2003, + month: 9, + day: 25, + hour: 10, + minute: 0, + second: 0, + micros: 0, + tzo: None, }; - parse_and_assert(pdt, info, "10h", None, None, false, false, - Some(default_rsdate), false, &HashMap::new()); + parse_and_assert( + pdt, + info, + "10h", + None, + None, + false, + false, + Some(default_rsdate), + false, + &HashMap::new(), + ); } #[test] fn test_parse_default11() { let info = ParserInfo::default(); - let default_rsdate = &NaiveDate::from_ymd_opt(2003, 9, 25).unwrap().and_hms_opt(0, 0, 0).unwrap(); + let default_rsdate = &NaiveDate::from_ymd_opt(2003, 9, 25) + .unwrap() + .and_hms_opt(0, 0, 0) + .unwrap(); let pdt = PyDateTime { - year: 2003, month: 9, day: 25, - hour: 10, minute: 36, second: 0, - micros: 0, tzo: None + year: 2003, + month: 9, + day: 25, + hour: 10, + minute: 36, + second: 0, + micros: 0, + tzo: None, }; - parse_and_assert(pdt, info, "10 h 36", None, None, false, false, - Some(default_rsdate), false, &HashMap::new()); + parse_and_assert( + pdt, + info, + "10 h 36", + None, + None, + false, + false, + Some(default_rsdate), + false, + &HashMap::new(), + ); } #[test] fn test_parse_default12() { let info = ParserInfo::default(); - let default_rsdate = &NaiveDate::from_ymd_opt(2003, 9, 25).unwrap().and_hms_opt(0, 0, 0).unwrap(); + let default_rsdate = &NaiveDate::from_ymd_opt(2003, 9, 25) + .unwrap() + .and_hms_opt(0, 0, 0) + .unwrap(); let pdt = PyDateTime { - year: 2003, month: 9, day: 25, - hour: 10, minute: 36, second: 30, - micros: 0, tzo: None + year: 2003, + month: 9, + day: 25, + hour: 10, + minute: 36, + second: 30, + micros: 0, + tzo: None, }; - parse_and_assert(pdt, info, "10 h 36.5", None, None, false, false, - Some(default_rsdate), false, &HashMap::new()); + parse_and_assert( + pdt, + info, + "10 h 36.5", + None, + None, + false, + false, + Some(default_rsdate), + false, + &HashMap::new(), + ); } #[test] fn test_parse_default13() { let info = ParserInfo::default(); - let default_rsdate = &NaiveDate::from_ymd_opt(2003, 9, 25).unwrap().and_hms_opt(0, 0, 0).unwrap(); + let default_rsdate = &NaiveDate::from_ymd_opt(2003, 9, 25) + .unwrap() + .and_hms_opt(0, 0, 0) + .unwrap(); let pdt = PyDateTime { - year: 2003, month: 9, day: 25, - hour: 0, minute: 36, second: 5, - micros: 0, tzo: None + year: 2003, + month: 9, + day: 25, + hour: 0, + minute: 36, + second: 5, + micros: 0, + tzo: None, }; - parse_and_assert(pdt, info, "36 m 5", None, None, false, false, - Some(default_rsdate), false, &HashMap::new()); + parse_and_assert( + pdt, + info, + "36 m 5", + None, + None, + false, + false, + Some(default_rsdate), + false, + &HashMap::new(), + ); } #[test] fn test_parse_default14() { let info = ParserInfo::default(); - let default_rsdate = &NaiveDate::from_ymd_opt(2003, 9, 25).unwrap().and_hms_opt(0, 0, 0).unwrap(); + let default_rsdate = &NaiveDate::from_ymd_opt(2003, 9, 25) + .unwrap() + .and_hms_opt(0, 0, 0) + .unwrap(); let pdt = PyDateTime { - year: 2003, month: 9, day: 25, - hour: 0, minute: 36, second: 5, - micros: 0, tzo: None + year: 2003, + month: 9, + day: 25, + hour: 0, + minute: 36, + second: 5, + micros: 0, + tzo: None, }; - parse_and_assert(pdt, info, "36 m 5 s", None, None, false, false, - Some(default_rsdate), false, &HashMap::new()); + parse_and_assert( + pdt, + info, + "36 m 5 s", + None, + None, + false, + false, + Some(default_rsdate), + false, + &HashMap::new(), + ); } #[test] fn test_parse_default15() { let info = ParserInfo::default(); - let default_rsdate = &NaiveDate::from_ymd_opt(2003, 9, 25).unwrap().and_hms_opt(0, 0, 0).unwrap(); + let default_rsdate = &NaiveDate::from_ymd_opt(2003, 9, 25) + .unwrap() + .and_hms_opt(0, 0, 0) + .unwrap(); let pdt = PyDateTime { - year: 2003, month: 9, day: 25, - hour: 0, minute: 36, second: 5, - micros: 0, tzo: None + year: 2003, + month: 9, + day: 25, + hour: 0, + minute: 36, + second: 5, + micros: 0, + tzo: None, }; - parse_and_assert(pdt, info, "36 m 05", None, None, false, false, - Some(default_rsdate), false, &HashMap::new()); + parse_and_assert( + pdt, + info, + "36 m 05", + None, + None, + false, + false, + Some(default_rsdate), + false, + &HashMap::new(), + ); } #[test] fn test_parse_default16() { let info = ParserInfo::default(); - let default_rsdate = &NaiveDate::from_ymd_opt(2003, 9, 25).unwrap().and_hms_opt(0, 0, 0).unwrap(); + let default_rsdate = &NaiveDate::from_ymd_opt(2003, 9, 25) + .unwrap() + .and_hms_opt(0, 0, 0) + .unwrap(); let pdt = PyDateTime { - year: 2003, month: 9, day: 25, - hour: 0, minute: 36, second: 5, - micros: 0, tzo: None + year: 2003, + month: 9, + day: 25, + hour: 0, + minute: 36, + second: 5, + micros: 0, + tzo: None, }; - parse_and_assert(pdt, info, "36 m 05 s", None, None, false, false, - Some(default_rsdate), false, &HashMap::new()); + parse_and_assert( + pdt, + info, + "36 m 05 s", + None, + None, + false, + false, + Some(default_rsdate), + false, + &HashMap::new(), + ); } #[test] fn test_parse_default17() { let info = ParserInfo::default(); - let default_rsdate = &NaiveDate::from_ymd_opt(2003, 9, 25).unwrap().and_hms_opt(0, 0, 0).unwrap(); + let default_rsdate = &NaiveDate::from_ymd_opt(2003, 9, 25) + .unwrap() + .and_hms_opt(0, 0, 0) + .unwrap(); let pdt = PyDateTime { - year: 2003, month: 9, day: 25, - hour: 10, minute: 0, second: 0, - micros: 0, tzo: None + year: 2003, + month: 9, + day: 25, + hour: 10, + minute: 0, + second: 0, + micros: 0, + tzo: None, }; - parse_and_assert(pdt, info, "10h am", None, None, false, false, - Some(default_rsdate), false, &HashMap::new()); + parse_and_assert( + pdt, + info, + "10h am", + None, + None, + false, + false, + Some(default_rsdate), + false, + &HashMap::new(), + ); } #[test] fn test_parse_default18() { let info = ParserInfo::default(); - let default_rsdate = &NaiveDate::from_ymd_opt(2003, 9, 25).unwrap().and_hms_opt(0, 0, 0).unwrap(); + let default_rsdate = &NaiveDate::from_ymd_opt(2003, 9, 25) + .unwrap() + .and_hms_opt(0, 0, 0) + .unwrap(); let pdt = PyDateTime { - year: 2003, month: 9, day: 25, - hour: 22, minute: 0, second: 0, - micros: 0, tzo: None + year: 2003, + month: 9, + day: 25, + hour: 22, + minute: 0, + second: 0, + micros: 0, + tzo: None, }; - parse_and_assert(pdt, info, "10h pm", None, None, false, false, - Some(default_rsdate), false, &HashMap::new()); + parse_and_assert( + pdt, + info, + "10h pm", + None, + None, + false, + false, + Some(default_rsdate), + false, + &HashMap::new(), + ); } #[test] fn test_parse_default19() { let info = ParserInfo::default(); - let default_rsdate = &NaiveDate::from_ymd_opt(2003, 9, 25).unwrap().and_hms_opt(0, 0, 0).unwrap(); + let default_rsdate = &NaiveDate::from_ymd_opt(2003, 9, 25) + .unwrap() + .and_hms_opt(0, 0, 0) + .unwrap(); let pdt = PyDateTime { - year: 2003, month: 9, day: 25, - hour: 10, minute: 0, second: 0, - micros: 0, tzo: None + year: 2003, + month: 9, + day: 25, + hour: 10, + minute: 0, + second: 0, + micros: 0, + tzo: None, }; - parse_and_assert(pdt, info, "10am", None, None, false, false, - Some(default_rsdate), false, &HashMap::new()); + parse_and_assert( + pdt, + info, + "10am", + None, + None, + false, + false, + Some(default_rsdate), + false, + &HashMap::new(), + ); } #[test] fn test_parse_default20() { let info = ParserInfo::default(); - let default_rsdate = &NaiveDate::from_ymd_opt(2003, 9, 25).unwrap().and_hms_opt(0, 0, 0).unwrap(); + let default_rsdate = &NaiveDate::from_ymd_opt(2003, 9, 25) + .unwrap() + .and_hms_opt(0, 0, 0) + .unwrap(); let pdt = PyDateTime { - year: 2003, month: 9, day: 25, - hour: 22, minute: 0, second: 0, - micros: 0, tzo: None + year: 2003, + month: 9, + day: 25, + hour: 22, + minute: 0, + second: 0, + micros: 0, + tzo: None, }; - parse_and_assert(pdt, info, "10pm", None, None, false, false, - Some(default_rsdate), false, &HashMap::new()); + parse_and_assert( + pdt, + info, + "10pm", + None, + None, + false, + false, + Some(default_rsdate), + false, + &HashMap::new(), + ); } #[test] fn test_parse_default21() { let info = ParserInfo::default(); - let default_rsdate = &NaiveDate::from_ymd_opt(2003, 9, 25).unwrap().and_hms_opt(0, 0, 0).unwrap(); + let default_rsdate = &NaiveDate::from_ymd_opt(2003, 9, 25) + .unwrap() + .and_hms_opt(0, 0, 0) + .unwrap(); let pdt = PyDateTime { - year: 2003, month: 9, day: 25, - hour: 10, minute: 0, second: 0, - micros: 0, tzo: None + year: 2003, + month: 9, + day: 25, + hour: 10, + minute: 0, + second: 0, + micros: 0, + tzo: None, }; - parse_and_assert(pdt, info, "10:00 am", None, None, false, false, - Some(default_rsdate), false, &HashMap::new()); + parse_and_assert( + pdt, + info, + "10:00 am", + None, + None, + false, + false, + Some(default_rsdate), + false, + &HashMap::new(), + ); } #[test] fn test_parse_default22() { let info = ParserInfo::default(); - let default_rsdate = &NaiveDate::from_ymd_opt(2003, 9, 25).unwrap().and_hms_opt(0, 0, 0).unwrap(); + let default_rsdate = &NaiveDate::from_ymd_opt(2003, 9, 25) + .unwrap() + .and_hms_opt(0, 0, 0) + .unwrap(); let pdt = PyDateTime { - year: 2003, month: 9, day: 25, - hour: 22, minute: 0, second: 0, - micros: 0, tzo: None + year: 2003, + month: 9, + day: 25, + hour: 22, + minute: 0, + second: 0, + micros: 0, + tzo: None, }; - parse_and_assert(pdt, info, "10:00 pm", None, None, false, false, - Some(default_rsdate), false, &HashMap::new()); + parse_and_assert( + pdt, + info, + "10:00 pm", + None, + None, + false, + false, + Some(default_rsdate), + false, + &HashMap::new(), + ); } #[test] fn test_parse_default23() { let info = ParserInfo::default(); - let default_rsdate = &NaiveDate::from_ymd_opt(2003, 9, 25).unwrap().and_hms_opt(0, 0, 0).unwrap(); + let default_rsdate = &NaiveDate::from_ymd_opt(2003, 9, 25) + .unwrap() + .and_hms_opt(0, 0, 0) + .unwrap(); let pdt = PyDateTime { - year: 2003, month: 9, day: 25, - hour: 10, minute: 0, second: 0, - micros: 0, tzo: None + year: 2003, + month: 9, + day: 25, + hour: 10, + minute: 0, + second: 0, + micros: 0, + tzo: None, }; - parse_and_assert(pdt, info, "10:00am", None, None, false, false, - Some(default_rsdate), false, &HashMap::new()); + parse_and_assert( + pdt, + info, + "10:00am", + None, + None, + false, + false, + Some(default_rsdate), + false, + &HashMap::new(), + ); } #[test] fn test_parse_default24() { let info = ParserInfo::default(); - let default_rsdate = &NaiveDate::from_ymd_opt(2003, 9, 25).unwrap().and_hms_opt(0, 0, 0).unwrap(); + let default_rsdate = &NaiveDate::from_ymd_opt(2003, 9, 25) + .unwrap() + .and_hms_opt(0, 0, 0) + .unwrap(); let pdt = PyDateTime { - year: 2003, month: 9, day: 25, - hour: 22, minute: 0, second: 0, - micros: 0, tzo: None + year: 2003, + month: 9, + day: 25, + hour: 22, + minute: 0, + second: 0, + micros: 0, + tzo: None, }; - parse_and_assert(pdt, info, "10:00pm", None, None, false, false, - Some(default_rsdate), false, &HashMap::new()); + parse_and_assert( + pdt, + info, + "10:00pm", + None, + None, + false, + false, + Some(default_rsdate), + false, + &HashMap::new(), + ); } #[test] fn test_parse_default25() { let info = ParserInfo::default(); - let default_rsdate = &NaiveDate::from_ymd_opt(2003, 9, 25).unwrap().and_hms_opt(0, 0, 0).unwrap(); + let default_rsdate = &NaiveDate::from_ymd_opt(2003, 9, 25) + .unwrap() + .and_hms_opt(0, 0, 0) + .unwrap(); let pdt = PyDateTime { - year: 2003, month: 9, day: 25, - hour: 10, minute: 0, second: 0, - micros: 0, tzo: None + year: 2003, + month: 9, + day: 25, + hour: 10, + minute: 0, + second: 0, + micros: 0, + tzo: None, }; - parse_and_assert(pdt, info, "10:00a.m", None, None, false, false, - Some(default_rsdate), false, &HashMap::new()); + parse_and_assert( + pdt, + info, + "10:00a.m", + None, + None, + false, + false, + Some(default_rsdate), + false, + &HashMap::new(), + ); } #[test] fn test_parse_default26() { let info = ParserInfo::default(); - let default_rsdate = &NaiveDate::from_ymd_opt(2003, 9, 25).unwrap().and_hms_opt(0, 0, 0).unwrap(); + let default_rsdate = &NaiveDate::from_ymd_opt(2003, 9, 25) + .unwrap() + .and_hms_opt(0, 0, 0) + .unwrap(); let pdt = PyDateTime { - year: 2003, month: 9, day: 25, - hour: 22, minute: 0, second: 0, - micros: 0, tzo: None + year: 2003, + month: 9, + day: 25, + hour: 22, + minute: 0, + second: 0, + micros: 0, + tzo: None, }; - parse_and_assert(pdt, info, "10:00p.m", None, None, false, false, - Some(default_rsdate), false, &HashMap::new()); + parse_and_assert( + pdt, + info, + "10:00p.m", + None, + None, + false, + false, + Some(default_rsdate), + false, + &HashMap::new(), + ); } #[test] fn test_parse_default27() { let info = ParserInfo::default(); - let default_rsdate = &NaiveDate::from_ymd_opt(2003, 9, 25).unwrap().and_hms_opt(0, 0, 0).unwrap(); + let default_rsdate = &NaiveDate::from_ymd_opt(2003, 9, 25) + .unwrap() + .and_hms_opt(0, 0, 0) + .unwrap(); let pdt = PyDateTime { - year: 2003, month: 9, day: 25, - hour: 10, minute: 0, second: 0, - micros: 0, tzo: None + year: 2003, + month: 9, + day: 25, + hour: 10, + minute: 0, + second: 0, + micros: 0, + tzo: None, }; - parse_and_assert(pdt, info, "10:00a.m.", None, None, false, false, - Some(default_rsdate), false, &HashMap::new()); + parse_and_assert( + pdt, + info, + "10:00a.m.", + None, + None, + false, + false, + Some(default_rsdate), + false, + &HashMap::new(), + ); } #[test] fn test_parse_default28() { let info = ParserInfo::default(); - let default_rsdate = &NaiveDate::from_ymd_opt(2003, 9, 25).unwrap().and_hms_opt(0, 0, 0).unwrap(); + let default_rsdate = &NaiveDate::from_ymd_opt(2003, 9, 25) + .unwrap() + .and_hms_opt(0, 0, 0) + .unwrap(); let pdt = PyDateTime { - year: 2003, month: 9, day: 25, - hour: 22, minute: 0, second: 0, - micros: 0, tzo: None + year: 2003, + month: 9, + day: 25, + hour: 22, + minute: 0, + second: 0, + micros: 0, + tzo: None, }; - parse_and_assert(pdt, info, "10:00p.m.", None, None, false, false, - Some(default_rsdate), false, &HashMap::new()); + parse_and_assert( + pdt, + info, + "10:00p.m.", + None, + None, + false, + false, + Some(default_rsdate), + false, + &HashMap::new(), + ); } #[test] fn test_parse_default29() { let info = ParserInfo::default(); - let default_rsdate = &NaiveDate::from_ymd_opt(2003, 9, 25).unwrap().and_hms_opt(0, 0, 0).unwrap(); + let default_rsdate = &NaiveDate::from_ymd_opt(2003, 9, 25) + .unwrap() + .and_hms_opt(0, 0, 0) + .unwrap(); let pdt = PyDateTime { - year: 2003, month: 10, day: 25, - hour: 0, minute: 0, second: 0, - micros: 0, tzo: None + year: 2003, + month: 10, + day: 25, + hour: 0, + minute: 0, + second: 0, + micros: 0, + tzo: None, }; - parse_and_assert(pdt, info, "October", None, None, false, false, - Some(default_rsdate), false, &HashMap::new()); + parse_and_assert( + pdt, + info, + "October", + None, + None, + false, + false, + Some(default_rsdate), + false, + &HashMap::new(), + ); } #[test] fn test_parse_default30() { let info = ParserInfo::default(); - let default_rsdate = &NaiveDate::from_ymd_opt(2003, 9, 25).unwrap().and_hms_opt(0, 0, 0).unwrap(); + let default_rsdate = &NaiveDate::from_ymd_opt(2003, 9, 25) + .unwrap() + .and_hms_opt(0, 0, 0) + .unwrap(); let pdt = PyDateTime { - year: 2000, month: 12, day: 31, - hour: 0, minute: 0, second: 0, - micros: 0, tzo: None + year: 2000, + month: 12, + day: 31, + hour: 0, + minute: 0, + second: 0, + micros: 0, + tzo: None, }; - parse_and_assert(pdt, info, "31-Dec-00", None, None, false, false, - Some(default_rsdate), false, &HashMap::new()); + parse_and_assert( + pdt, + info, + "31-Dec-00", + None, + None, + false, + false, + Some(default_rsdate), + false, + &HashMap::new(), + ); } #[test] fn test_parse_default31() { let info = ParserInfo::default(); - let default_rsdate = &NaiveDate::from_ymd_opt(2003, 9, 25).unwrap().and_hms_opt(0, 0, 0).unwrap(); + let default_rsdate = &NaiveDate::from_ymd_opt(2003, 9, 25) + .unwrap() + .and_hms_opt(0, 0, 0) + .unwrap(); let pdt = PyDateTime { - year: 2003, month: 9, day: 25, - hour: 0, minute: 1, second: 2, - micros: 0, tzo: None + year: 2003, + month: 9, + day: 25, + hour: 0, + minute: 1, + second: 2, + micros: 0, + tzo: None, }; - parse_and_assert(pdt, info, "0:01:02", None, None, false, false, - Some(default_rsdate), false, &HashMap::new()); + parse_and_assert( + pdt, + info, + "0:01:02", + None, + None, + false, + false, + Some(default_rsdate), + false, + &HashMap::new(), + ); } #[test] fn test_parse_default32() { let info = ParserInfo::default(); - let default_rsdate = &NaiveDate::from_ymd_opt(2003, 9, 25).unwrap().and_hms_opt(0, 0, 0).unwrap(); + let default_rsdate = &NaiveDate::from_ymd_opt(2003, 9, 25) + .unwrap() + .and_hms_opt(0, 0, 0) + .unwrap(); let pdt = PyDateTime { - year: 2003, month: 9, day: 25, - hour: 0, minute: 1, second: 2, - micros: 0, tzo: None + year: 2003, + month: 9, + day: 25, + hour: 0, + minute: 1, + second: 2, + micros: 0, + tzo: None, }; - parse_and_assert(pdt, info, "12h 01m02s am", None, None, false, false, - Some(default_rsdate), false, &HashMap::new()); + parse_and_assert( + pdt, + info, + "12h 01m02s am", + None, + None, + false, + false, + Some(default_rsdate), + false, + &HashMap::new(), + ); } #[test] fn test_parse_default33() { let info = ParserInfo::default(); - let default_rsdate = &NaiveDate::from_ymd_opt(2003, 9, 25).unwrap().and_hms_opt(0, 0, 0).unwrap(); + let default_rsdate = &NaiveDate::from_ymd_opt(2003, 9, 25) + .unwrap() + .and_hms_opt(0, 0, 0) + .unwrap(); let pdt = PyDateTime { - year: 2003, month: 9, day: 25, - hour: 12, minute: 8, second: 0, - micros: 0, tzo: None + year: 2003, + month: 9, + day: 25, + hour: 12, + minute: 8, + second: 0, + micros: 0, + tzo: None, }; - parse_and_assert(pdt, info, "12:08 PM", None, None, false, false, - Some(default_rsdate), false, &HashMap::new()); + parse_and_assert( + pdt, + info, + "12:08 PM", + None, + None, + false, + false, + Some(default_rsdate), + false, + &HashMap::new(), + ); } #[test] fn test_parse_default34() { let info = ParserInfo::default(); - let default_rsdate = &NaiveDate::from_ymd_opt(2003, 9, 25).unwrap().and_hms_opt(0, 0, 0).unwrap(); + let default_rsdate = &NaiveDate::from_ymd_opt(2003, 9, 25) + .unwrap() + .and_hms_opt(0, 0, 0) + .unwrap(); let pdt = PyDateTime { - year: 2003, month: 9, day: 25, - hour: 1, minute: 2, second: 3, - micros: 0, tzo: None + year: 2003, + month: 9, + day: 25, + hour: 1, + minute: 2, + second: 3, + micros: 0, + tzo: None, }; - parse_and_assert(pdt, info, "01h02m03", None, None, false, false, - Some(default_rsdate), false, &HashMap::new()); + parse_and_assert( + pdt, + info, + "01h02m03", + None, + None, + false, + false, + Some(default_rsdate), + false, + &HashMap::new(), + ); } #[test] fn test_parse_default35() { let info = ParserInfo::default(); - let default_rsdate = &NaiveDate::from_ymd_opt(2003, 9, 25).unwrap().and_hms_opt(0, 0, 0).unwrap(); + let default_rsdate = &NaiveDate::from_ymd_opt(2003, 9, 25) + .unwrap() + .and_hms_opt(0, 0, 0) + .unwrap(); let pdt = PyDateTime { - year: 2003, month: 9, day: 25, - hour: 1, minute: 2, second: 0, - micros: 0, tzo: None + year: 2003, + month: 9, + day: 25, + hour: 1, + minute: 2, + second: 0, + micros: 0, + tzo: None, }; - parse_and_assert(pdt, info, "01h02", None, None, false, false, - Some(default_rsdate), false, &HashMap::new()); + parse_and_assert( + pdt, + info, + "01h02", + None, + None, + false, + false, + Some(default_rsdate), + false, + &HashMap::new(), + ); } #[test] fn test_parse_default36() { let info = ParserInfo::default(); - let default_rsdate = &NaiveDate::from_ymd_opt(2003, 9, 25).unwrap().and_hms_opt(0, 0, 0).unwrap(); + let default_rsdate = &NaiveDate::from_ymd_opt(2003, 9, 25) + .unwrap() + .and_hms_opt(0, 0, 0) + .unwrap(); let pdt = PyDateTime { - year: 2003, month: 9, day: 25, - hour: 1, minute: 0, second: 2, - micros: 0, tzo: None + year: 2003, + month: 9, + day: 25, + hour: 1, + minute: 0, + second: 2, + micros: 0, + tzo: None, }; - parse_and_assert(pdt, info, "01h02s", None, None, false, false, - Some(default_rsdate), false, &HashMap::new()); + parse_and_assert( + pdt, + info, + "01h02s", + None, + None, + false, + false, + Some(default_rsdate), + false, + &HashMap::new(), + ); } #[test] fn test_parse_default37() { let info = ParserInfo::default(); - let default_rsdate = &NaiveDate::from_ymd_opt(2003, 9, 25).unwrap().and_hms_opt(0, 0, 0).unwrap(); + let default_rsdate = &NaiveDate::from_ymd_opt(2003, 9, 25) + .unwrap() + .and_hms_opt(0, 0, 0) + .unwrap(); let pdt = PyDateTime { - year: 2003, month: 9, day: 25, - hour: 0, minute: 1, second: 2, - micros: 0, tzo: None + year: 2003, + month: 9, + day: 25, + hour: 0, + minute: 1, + second: 2, + micros: 0, + tzo: None, }; - parse_and_assert(pdt, info, "01m02", None, None, false, false, - Some(default_rsdate), false, &HashMap::new()); + parse_and_assert( + pdt, + info, + "01m02", + None, + None, + false, + false, + Some(default_rsdate), + false, + &HashMap::new(), + ); } #[test] fn test_parse_default38() { let info = ParserInfo::default(); - let default_rsdate = &NaiveDate::from_ymd_opt(2003, 9, 25).unwrap().and_hms_opt(0, 0, 0).unwrap(); + let default_rsdate = &NaiveDate::from_ymd_opt(2003, 9, 25) + .unwrap() + .and_hms_opt(0, 0, 0) + .unwrap(); let pdt = PyDateTime { - year: 2003, month: 9, day: 25, - hour: 2, minute: 1, second: 0, - micros: 0, tzo: None + year: 2003, + month: 9, + day: 25, + hour: 2, + minute: 1, + second: 0, + micros: 0, + tzo: None, }; - parse_and_assert(pdt, info, "01m02h", None, None, false, false, - Some(default_rsdate), false, &HashMap::new()); + parse_and_assert( + pdt, + info, + "01m02h", + None, + None, + false, + false, + Some(default_rsdate), + false, + &HashMap::new(), + ); } #[test] fn test_parse_default39() { let info = ParserInfo::default(); - let default_rsdate = &NaiveDate::from_ymd_opt(2003, 9, 25).unwrap().and_hms_opt(0, 0, 0).unwrap(); + let default_rsdate = &NaiveDate::from_ymd_opt(2003, 9, 25) + .unwrap() + .and_hms_opt(0, 0, 0) + .unwrap(); let pdt = PyDateTime { - year: 2004, month: 4, day: 10, - hour: 11, minute: 30, second: 0, - micros: 0, tzo: None + year: 2004, + month: 4, + day: 10, + hour: 11, + minute: 30, + second: 0, + micros: 0, + tzo: None, }; - parse_and_assert(pdt, info, "2004 10 Apr 11h30m", None, None, false, false, - Some(default_rsdate), false, &HashMap::new()); + parse_and_assert( + pdt, + info, + "2004 10 Apr 11h30m", + None, + None, + false, + false, + Some(default_rsdate), + false, + &HashMap::new(), + ); } #[test] fn test_parse_default40() { let info = ParserInfo::default(); - let default_rsdate = &NaiveDate::from_ymd_opt(2003, 9, 25).unwrap().and_hms_opt(0, 0, 0).unwrap(); + let default_rsdate = &NaiveDate::from_ymd_opt(2003, 9, 25) + .unwrap() + .and_hms_opt(0, 0, 0) + .unwrap(); let pdt = PyDateTime { - year: 2003, month: 9, day: 3, - hour: 0, minute: 0, second: 0, - micros: 0, tzo: None + year: 2003, + month: 9, + day: 3, + hour: 0, + minute: 0, + second: 0, + micros: 0, + tzo: None, }; - parse_and_assert(pdt, info, "Sep 03", None, None, false, false, - Some(default_rsdate), false, &HashMap::new()); + parse_and_assert( + pdt, + info, + "Sep 03", + None, + None, + false, + false, + Some(default_rsdate), + false, + &HashMap::new(), + ); } #[test] fn test_parse_default41() { let info = ParserInfo::default(); - let default_rsdate = &NaiveDate::from_ymd_opt(2003, 9, 25).unwrap().and_hms_opt(0, 0, 0).unwrap(); + let default_rsdate = &NaiveDate::from_ymd_opt(2003, 9, 25) + .unwrap() + .and_hms_opt(0, 0, 0) + .unwrap(); let pdt = PyDateTime { - year: 2003, month: 9, day: 25, - hour: 0, minute: 0, second: 0, - micros: 0, tzo: None + year: 2003, + month: 9, + day: 25, + hour: 0, + minute: 0, + second: 0, + micros: 0, + tzo: None, }; - parse_and_assert(pdt, info, "Sep of 03", None, None, false, false, - Some(default_rsdate), false, &HashMap::new()); + parse_and_assert( + pdt, + info, + "Sep of 03", + None, + None, + false, + false, + Some(default_rsdate), + false, + &HashMap::new(), + ); } #[test] fn test_parse_default42() { let info = ParserInfo::default(); - let default_rsdate = &NaiveDate::from_ymd_opt(2003, 9, 25).unwrap().and_hms_opt(0, 0, 0).unwrap(); + let default_rsdate = &NaiveDate::from_ymd_opt(2003, 9, 25) + .unwrap() + .and_hms_opt(0, 0, 0) + .unwrap(); let pdt = PyDateTime { - year: 2017, month: 11, day: 25, - hour: 2, minute: 17, second: 0, - micros: 0, tzo: None + year: 2017, + month: 11, + day: 25, + hour: 2, + minute: 17, + second: 0, + micros: 0, + tzo: None, }; - parse_and_assert(pdt, info, "02:17NOV2017", None, None, false, false, - Some(default_rsdate), false, &HashMap::new()); + parse_and_assert( + pdt, + info, + "02:17NOV2017", + None, + None, + false, + false, + Some(default_rsdate), + false, + &HashMap::new(), + ); } #[test] fn test_parse_default43() { let info = ParserInfo::default(); - let default_rsdate = &NaiveDate::from_ymd_opt(2003, 9, 25).unwrap().and_hms_opt(0, 0, 0).unwrap(); + let default_rsdate = &NaiveDate::from_ymd_opt(2003, 9, 25) + .unwrap() + .and_hms_opt(0, 0, 0) + .unwrap(); let pdt = PyDateTime { - year: 2003, month: 9, day: 25, - hour: 10, minute: 36, second: 28, - micros: 0, tzo: None + year: 2003, + month: 9, + day: 25, + hour: 10, + minute: 36, + second: 28, + micros: 0, + tzo: None, }; - parse_and_assert(pdt, info, "Thu Sep 10:36:28", None, None, false, false, - Some(default_rsdate), false, &HashMap::new()); + parse_and_assert( + pdt, + info, + "Thu Sep 10:36:28", + None, + None, + false, + false, + Some(default_rsdate), + false, + &HashMap::new(), + ); } #[test] fn test_parse_default44() { let info = ParserInfo::default(); - let default_rsdate = &NaiveDate::from_ymd_opt(2003, 9, 25).unwrap().and_hms_opt(0, 0, 0).unwrap(); + let default_rsdate = &NaiveDate::from_ymd_opt(2003, 9, 25) + .unwrap() + .and_hms_opt(0, 0, 0) + .unwrap(); let pdt = PyDateTime { - year: 2003, month: 9, day: 25, - hour: 10, minute: 36, second: 28, - micros: 0, tzo: None + year: 2003, + month: 9, + day: 25, + hour: 10, + minute: 36, + second: 28, + micros: 0, + tzo: None, }; - parse_and_assert(pdt, info, "Thu 10:36:28", None, None, false, false, - Some(default_rsdate), false, &HashMap::new()); + parse_and_assert( + pdt, + info, + "Thu 10:36:28", + None, + None, + false, + false, + Some(default_rsdate), + false, + &HashMap::new(), + ); } #[test] fn test_parse_default45() { let info = ParserInfo::default(); - let default_rsdate = &NaiveDate::from_ymd_opt(2003, 9, 25).unwrap().and_hms_opt(0, 0, 0).unwrap(); + let default_rsdate = &NaiveDate::from_ymd_opt(2003, 9, 25) + .unwrap() + .and_hms_opt(0, 0, 0) + .unwrap(); let pdt = PyDateTime { - year: 2003, month: 10, day: 1, - hour: 0, minute: 0, second: 0, - micros: 0, tzo: None + year: 2003, + month: 10, + day: 1, + hour: 0, + minute: 0, + second: 0, + micros: 0, + tzo: None, }; - parse_and_assert(pdt, info, "Wed", None, None, false, false, - Some(default_rsdate), false, &HashMap::new()); + parse_and_assert( + pdt, + info, + "Wed", + None, + None, + false, + false, + Some(default_rsdate), + false, + &HashMap::new(), + ); } #[test] fn test_parse_default46() { let info = ParserInfo::default(); - let default_rsdate = &NaiveDate::from_ymd_opt(2003, 9, 25).unwrap().and_hms_opt(0, 0, 0).unwrap(); + let default_rsdate = &NaiveDate::from_ymd_opt(2003, 9, 25) + .unwrap() + .and_hms_opt(0, 0, 0) + .unwrap(); let pdt = PyDateTime { - year: 2003, month: 10, day: 1, - hour: 0, minute: 0, second: 0, - micros: 0, tzo: None + year: 2003, + month: 10, + day: 1, + hour: 0, + minute: 0, + second: 0, + micros: 0, + tzo: None, }; - parse_and_assert(pdt, info, "Wednesday", None, None, false, false, - Some(default_rsdate), false, &HashMap::new()); + parse_and_assert( + pdt, + info, + "Wednesday", + None, + None, + false, + false, + Some(default_rsdate), + false, + &HashMap::new(), + ); } #[test] fn test_parse_simple0() { let pdt = PyDateTime { - year: 2003, month: 9, day: 25, - hour: 10, minute: 36, second: 28, - micros: 0, tzo: None, + year: 2003, + month: 9, + day: 25, + hour: 10, + minute: 36, + second: 28, + micros: 0, + tzo: None, }; parse_and_assert_simple(pdt, "Thu Sep 25 10:36:28 2003"); } @@ -743,9 +1654,14 @@ fn test_parse_simple0() { #[test] fn test_parse_simple1() { let pdt = PyDateTime { - year: 2003, month: 9, day: 25, - hour: 0, minute: 0, second: 0, - micros: 0, tzo: None, + year: 2003, + month: 9, + day: 25, + hour: 0, + minute: 0, + second: 0, + micros: 0, + tzo: None, }; parse_and_assert_simple(pdt, "Thu Sep 25 2003"); } @@ -753,9 +1669,14 @@ fn test_parse_simple1() { #[test] fn test_parse_simple2() { let pdt = PyDateTime { - year: 2003, month: 9, day: 25, - hour: 10, minute: 49, second: 41, - micros: 0, tzo: None, + year: 2003, + month: 9, + day: 25, + hour: 10, + minute: 49, + second: 41, + micros: 0, + tzo: None, }; parse_and_assert_simple(pdt, "2003-09-25T10:49:41"); } @@ -763,9 +1684,14 @@ fn test_parse_simple2() { #[test] fn test_parse_simple3() { let pdt = PyDateTime { - year: 2003, month: 9, day: 25, - hour: 10, minute: 49, second: 0, - micros: 0, tzo: None, + year: 2003, + month: 9, + day: 25, + hour: 10, + minute: 49, + second: 0, + micros: 0, + tzo: None, }; parse_and_assert_simple(pdt, "2003-09-25T10:49"); } @@ -773,9 +1699,14 @@ fn test_parse_simple3() { #[test] fn test_parse_simple4() { let pdt = PyDateTime { - year: 2003, month: 9, day: 25, - hour: 10, minute: 0, second: 0, - micros: 0, tzo: None, + year: 2003, + month: 9, + day: 25, + hour: 10, + minute: 0, + second: 0, + micros: 0, + tzo: None, }; parse_and_assert_simple(pdt, "2003-09-25T10"); } @@ -783,9 +1714,14 @@ fn test_parse_simple4() { #[test] fn test_parse_simple5() { let pdt = PyDateTime { - year: 2003, month: 9, day: 25, - hour: 0, minute: 0, second: 0, - micros: 0, tzo: None, + year: 2003, + month: 9, + day: 25, + hour: 0, + minute: 0, + second: 0, + micros: 0, + tzo: None, }; parse_and_assert_simple(pdt, "2003-09-25"); } @@ -793,9 +1729,14 @@ fn test_parse_simple5() { #[test] fn test_parse_simple6() { let pdt = PyDateTime { - year: 2003, month: 9, day: 25, - hour: 10, minute: 49, second: 41, - micros: 0, tzo: None, + year: 2003, + month: 9, + day: 25, + hour: 10, + minute: 49, + second: 41, + micros: 0, + tzo: None, }; parse_and_assert_simple(pdt, "20030925T104941"); } @@ -803,9 +1744,14 @@ fn test_parse_simple6() { #[test] fn test_parse_simple7() { let pdt = PyDateTime { - year: 2003, month: 9, day: 25, - hour: 10, minute: 49, second: 0, - micros: 0, tzo: None, + year: 2003, + month: 9, + day: 25, + hour: 10, + minute: 49, + second: 0, + micros: 0, + tzo: None, }; parse_and_assert_simple(pdt, "20030925T1049"); } @@ -813,9 +1759,14 @@ fn test_parse_simple7() { #[test] fn test_parse_simple8() { let pdt = PyDateTime { - year: 2003, month: 9, day: 25, - hour: 10, minute: 0, second: 0, - micros: 0, tzo: None, + year: 2003, + month: 9, + day: 25, + hour: 10, + minute: 0, + second: 0, + micros: 0, + tzo: None, }; parse_and_assert_simple(pdt, "20030925T10"); } @@ -823,9 +1774,14 @@ fn test_parse_simple8() { #[test] fn test_parse_simple9() { let pdt = PyDateTime { - year: 2003, month: 9, day: 25, - hour: 0, minute: 0, second: 0, - micros: 0, tzo: None, + year: 2003, + month: 9, + day: 25, + hour: 0, + minute: 0, + second: 0, + micros: 0, + tzo: None, }; parse_and_assert_simple(pdt, "20030925"); } @@ -833,9 +1789,14 @@ fn test_parse_simple9() { #[test] fn test_parse_simple10() { let pdt = PyDateTime { - year: 2003, month: 9, day: 25, - hour: 10, minute: 49, second: 41, - micros: 502000, tzo: None, + year: 2003, + month: 9, + day: 25, + hour: 10, + minute: 49, + second: 41, + micros: 502000, + tzo: None, }; parse_and_assert_simple(pdt, "2003-09-25 10:49:41,502"); } @@ -843,9 +1804,14 @@ fn test_parse_simple10() { #[test] fn test_parse_simple11() { let pdt = PyDateTime { - year: 1997, month: 9, day: 2, - hour: 9, minute: 8, second: 0, - micros: 0, tzo: None, + year: 1997, + month: 9, + day: 2, + hour: 9, + minute: 8, + second: 0, + micros: 0, + tzo: None, }; parse_and_assert_simple(pdt, "199709020908"); } @@ -853,9 +1819,14 @@ fn test_parse_simple11() { #[test] fn test_parse_simple12() { let pdt = PyDateTime { - year: 1997, month: 9, day: 2, - hour: 9, minute: 8, second: 7, - micros: 0, tzo: None, + year: 1997, + month: 9, + day: 2, + hour: 9, + minute: 8, + second: 7, + micros: 0, + tzo: None, }; parse_and_assert_simple(pdt, "19970902090807"); } @@ -863,9 +1834,14 @@ fn test_parse_simple12() { #[test] fn test_parse_simple13() { let pdt = PyDateTime { - year: 2003, month: 9, day: 25, - hour: 0, minute: 0, second: 0, - micros: 0, tzo: None, + year: 2003, + month: 9, + day: 25, + hour: 0, + minute: 0, + second: 0, + micros: 0, + tzo: None, }; parse_and_assert_simple(pdt, "2003-09-25"); } @@ -873,9 +1849,14 @@ fn test_parse_simple13() { #[test] fn test_parse_simple14() { let pdt = PyDateTime { - year: 2003, month: 9, day: 25, - hour: 0, minute: 0, second: 0, - micros: 0, tzo: None, + year: 2003, + month: 9, + day: 25, + hour: 0, + minute: 0, + second: 0, + micros: 0, + tzo: None, }; parse_and_assert_simple(pdt, "09-25-2003"); } @@ -883,9 +1864,14 @@ fn test_parse_simple14() { #[test] fn test_parse_simple15() { let pdt = PyDateTime { - year: 2003, month: 9, day: 25, - hour: 0, minute: 0, second: 0, - micros: 0, tzo: None, + year: 2003, + month: 9, + day: 25, + hour: 0, + minute: 0, + second: 0, + micros: 0, + tzo: None, }; parse_and_assert_simple(pdt, "25-09-2003"); } @@ -893,9 +1879,14 @@ fn test_parse_simple15() { #[test] fn test_parse_simple16() { let pdt = PyDateTime { - year: 2003, month: 10, day: 9, - hour: 0, minute: 0, second: 0, - micros: 0, tzo: None, + year: 2003, + month: 10, + day: 9, + hour: 0, + minute: 0, + second: 0, + micros: 0, + tzo: None, }; parse_and_assert_simple(pdt, "10-09-2003"); } @@ -903,9 +1894,14 @@ fn test_parse_simple16() { #[test] fn test_parse_simple17() { let pdt = PyDateTime { - year: 2003, month: 10, day: 9, - hour: 0, minute: 0, second: 0, - micros: 0, tzo: None, + year: 2003, + month: 10, + day: 9, + hour: 0, + minute: 0, + second: 0, + micros: 0, + tzo: None, }; parse_and_assert_simple(pdt, "10-09-03"); } @@ -913,9 +1909,14 @@ fn test_parse_simple17() { #[test] fn test_parse_simple18() { let pdt = PyDateTime { - year: 2003, month: 9, day: 25, - hour: 0, minute: 0, second: 0, - micros: 0, tzo: None, + year: 2003, + month: 9, + day: 25, + hour: 0, + minute: 0, + second: 0, + micros: 0, + tzo: None, }; parse_and_assert_simple(pdt, "2003.09.25"); } @@ -923,9 +1924,14 @@ fn test_parse_simple18() { #[test] fn test_parse_simple19() { let pdt = PyDateTime { - year: 2003, month: 9, day: 25, - hour: 0, minute: 0, second: 0, - micros: 0, tzo: None, + year: 2003, + month: 9, + day: 25, + hour: 0, + minute: 0, + second: 0, + micros: 0, + tzo: None, }; parse_and_assert_simple(pdt, "09.25.2003"); } @@ -933,9 +1939,14 @@ fn test_parse_simple19() { #[test] fn test_parse_simple20() { let pdt = PyDateTime { - year: 2003, month: 9, day: 25, - hour: 0, minute: 0, second: 0, - micros: 0, tzo: None, + year: 2003, + month: 9, + day: 25, + hour: 0, + minute: 0, + second: 0, + micros: 0, + tzo: None, }; parse_and_assert_simple(pdt, "25.09.2003"); } @@ -943,9 +1954,14 @@ fn test_parse_simple20() { #[test] fn test_parse_simple21() { let pdt = PyDateTime { - year: 2003, month: 10, day: 9, - hour: 0, minute: 0, second: 0, - micros: 0, tzo: None, + year: 2003, + month: 10, + day: 9, + hour: 0, + minute: 0, + second: 0, + micros: 0, + tzo: None, }; parse_and_assert_simple(pdt, "10.09.2003"); } @@ -953,9 +1969,14 @@ fn test_parse_simple21() { #[test] fn test_parse_simple22() { let pdt = PyDateTime { - year: 2003, month: 10, day: 9, - hour: 0, minute: 0, second: 0, - micros: 0, tzo: None, + year: 2003, + month: 10, + day: 9, + hour: 0, + minute: 0, + second: 0, + micros: 0, + tzo: None, }; parse_and_assert_simple(pdt, "10.09.03"); } @@ -963,9 +1984,14 @@ fn test_parse_simple22() { #[test] fn test_parse_simple23() { let pdt = PyDateTime { - year: 2003, month: 9, day: 25, - hour: 0, minute: 0, second: 0, - micros: 0, tzo: None, + year: 2003, + month: 9, + day: 25, + hour: 0, + minute: 0, + second: 0, + micros: 0, + tzo: None, }; parse_and_assert_simple(pdt, "2003/09/25"); } @@ -973,9 +1999,14 @@ fn test_parse_simple23() { #[test] fn test_parse_simple24() { let pdt = PyDateTime { - year: 2003, month: 9, day: 25, - hour: 0, minute: 0, second: 0, - micros: 0, tzo: None, + year: 2003, + month: 9, + day: 25, + hour: 0, + minute: 0, + second: 0, + micros: 0, + tzo: None, }; parse_and_assert_simple(pdt, "09/25/2003"); } @@ -983,9 +2014,14 @@ fn test_parse_simple24() { #[test] fn test_parse_simple25() { let pdt = PyDateTime { - year: 2003, month: 9, day: 25, - hour: 0, minute: 0, second: 0, - micros: 0, tzo: None, + year: 2003, + month: 9, + day: 25, + hour: 0, + minute: 0, + second: 0, + micros: 0, + tzo: None, }; parse_and_assert_simple(pdt, "25/09/2003"); } @@ -993,9 +2029,14 @@ fn test_parse_simple25() { #[test] fn test_parse_simple26() { let pdt = PyDateTime { - year: 2003, month: 10, day: 9, - hour: 0, minute: 0, second: 0, - micros: 0, tzo: None, + year: 2003, + month: 10, + day: 9, + hour: 0, + minute: 0, + second: 0, + micros: 0, + tzo: None, }; parse_and_assert_simple(pdt, "10/09/2003"); } @@ -1003,9 +2044,14 @@ fn test_parse_simple26() { #[test] fn test_parse_simple27() { let pdt = PyDateTime { - year: 2003, month: 10, day: 9, - hour: 0, minute: 0, second: 0, - micros: 0, tzo: None, + year: 2003, + month: 10, + day: 9, + hour: 0, + minute: 0, + second: 0, + micros: 0, + tzo: None, }; parse_and_assert_simple(pdt, "10/09/03"); } @@ -1013,9 +2059,14 @@ fn test_parse_simple27() { #[test] fn test_parse_simple28() { let pdt = PyDateTime { - year: 2003, month: 9, day: 25, - hour: 0, minute: 0, second: 0, - micros: 0, tzo: None, + year: 2003, + month: 9, + day: 25, + hour: 0, + minute: 0, + second: 0, + micros: 0, + tzo: None, }; parse_and_assert_simple(pdt, "2003 09 25"); } @@ -1023,9 +2074,14 @@ fn test_parse_simple28() { #[test] fn test_parse_simple29() { let pdt = PyDateTime { - year: 2003, month: 9, day: 25, - hour: 0, minute: 0, second: 0, - micros: 0, tzo: None, + year: 2003, + month: 9, + day: 25, + hour: 0, + minute: 0, + second: 0, + micros: 0, + tzo: None, }; parse_and_assert_simple(pdt, "09 25 2003"); } @@ -1033,9 +2089,14 @@ fn test_parse_simple29() { #[test] fn test_parse_simple30() { let pdt = PyDateTime { - year: 2003, month: 9, day: 25, - hour: 0, minute: 0, second: 0, - micros: 0, tzo: None, + year: 2003, + month: 9, + day: 25, + hour: 0, + minute: 0, + second: 0, + micros: 0, + tzo: None, }; parse_and_assert_simple(pdt, "25 09 2003"); } @@ -1043,9 +2104,14 @@ fn test_parse_simple30() { #[test] fn test_parse_simple31() { let pdt = PyDateTime { - year: 2003, month: 10, day: 9, - hour: 0, minute: 0, second: 0, - micros: 0, tzo: None, + year: 2003, + month: 10, + day: 9, + hour: 0, + minute: 0, + second: 0, + micros: 0, + tzo: None, }; parse_and_assert_simple(pdt, "10 09 2003"); } @@ -1053,9 +2119,14 @@ fn test_parse_simple31() { #[test] fn test_parse_simple32() { let pdt = PyDateTime { - year: 2003, month: 10, day: 9, - hour: 0, minute: 0, second: 0, - micros: 0, tzo: None, + year: 2003, + month: 10, + day: 9, + hour: 0, + minute: 0, + second: 0, + micros: 0, + tzo: None, }; parse_and_assert_simple(pdt, "10 09 03"); } @@ -1063,9 +2134,14 @@ fn test_parse_simple32() { #[test] fn test_parse_simple33() { let pdt = PyDateTime { - year: 2003, month: 9, day: 25, - hour: 0, minute: 0, second: 0, - micros: 0, tzo: None, + year: 2003, + month: 9, + day: 25, + hour: 0, + minute: 0, + second: 0, + micros: 0, + tzo: None, }; parse_and_assert_simple(pdt, "25 09 03"); } @@ -1073,9 +2149,14 @@ fn test_parse_simple33() { #[test] fn test_parse_simple34() { let pdt = PyDateTime { - year: 2003, month: 9, day: 25, - hour: 0, minute: 0, second: 0, - micros: 0, tzo: None, + year: 2003, + month: 9, + day: 25, + hour: 0, + minute: 0, + second: 0, + micros: 0, + tzo: None, }; parse_and_assert_simple(pdt, "03 25 Sep"); } @@ -1083,9 +2164,14 @@ fn test_parse_simple34() { #[test] fn test_parse_simple35() { let pdt = PyDateTime { - year: 2025, month: 9, day: 3, - hour: 0, minute: 0, second: 0, - micros: 0, tzo: None, + year: 2025, + month: 9, + day: 3, + hour: 0, + minute: 0, + second: 0, + micros: 0, + tzo: None, }; parse_and_assert_simple(pdt, "25 03 Sep"); } @@ -1093,9 +2179,14 @@ fn test_parse_simple35() { #[test] fn test_parse_simple36() { let pdt = PyDateTime { - year: 1976, month: 7, day: 4, - hour: 0, minute: 1, second: 2, - micros: 0, tzo: None, + year: 1976, + month: 7, + day: 4, + hour: 0, + minute: 1, + second: 2, + micros: 0, + tzo: None, }; parse_and_assert_simple(pdt, " July 4 , 1976 12:01:02 am "); } @@ -1103,9 +2194,14 @@ fn test_parse_simple36() { #[test] fn test_parse_simple37() { let pdt = PyDateTime { - year: 1996, month: 7, day: 10, - hour: 0, minute: 0, second: 0, - micros: 0, tzo: None, + year: 1996, + month: 7, + day: 10, + hour: 0, + minute: 0, + second: 0, + micros: 0, + tzo: None, }; parse_and_assert_simple(pdt, "Wed, July 10, '96"); } @@ -1113,9 +2209,14 @@ fn test_parse_simple37() { #[test] fn test_parse_simple38() { let pdt = PyDateTime { - year: 1996, month: 7, day: 10, - hour: 12, minute: 8, second: 0, - micros: 0, tzo: None, + year: 1996, + month: 7, + day: 10, + hour: 12, + minute: 8, + second: 0, + micros: 0, + tzo: None, }; parse_and_assert_simple(pdt, "1996.July.10 AD 12:08 PM"); } @@ -1123,9 +2224,14 @@ fn test_parse_simple38() { #[test] fn test_parse_simple39() { let pdt = PyDateTime { - year: 1976, month: 7, day: 4, - hour: 0, minute: 0, second: 0, - micros: 0, tzo: None, + year: 1976, + month: 7, + day: 4, + hour: 0, + minute: 0, + second: 0, + micros: 0, + tzo: None, }; parse_and_assert_simple(pdt, "July 4, 1976"); } @@ -1133,9 +2239,14 @@ fn test_parse_simple39() { #[test] fn test_parse_simple40() { let pdt = PyDateTime { - year: 1976, month: 7, day: 4, - hour: 0, minute: 0, second: 0, - micros: 0, tzo: None, + year: 1976, + month: 7, + day: 4, + hour: 0, + minute: 0, + second: 0, + micros: 0, + tzo: None, }; parse_and_assert_simple(pdt, "7 4 1976"); } @@ -1143,9 +2254,14 @@ fn test_parse_simple40() { #[test] fn test_parse_simple41() { let pdt = PyDateTime { - year: 1976, month: 7, day: 4, - hour: 0, minute: 0, second: 0, - micros: 0, tzo: None, + year: 1976, + month: 7, + day: 4, + hour: 0, + minute: 0, + second: 0, + micros: 0, + tzo: None, }; parse_and_assert_simple(pdt, "4 jul 1976"); } @@ -1153,9 +2269,14 @@ fn test_parse_simple41() { #[test] fn test_parse_simple42() { let pdt = PyDateTime { - year: 1976, month: 7, day: 4, - hour: 0, minute: 0, second: 0, - micros: 0, tzo: None, + year: 1976, + month: 7, + day: 4, + hour: 0, + minute: 0, + second: 0, + micros: 0, + tzo: None, }; parse_and_assert_simple(pdt, "7-4-76"); } @@ -1163,9 +2284,14 @@ fn test_parse_simple42() { #[test] fn test_parse_simple43() { let pdt = PyDateTime { - year: 1976, month: 7, day: 4, - hour: 0, minute: 0, second: 0, - micros: 0, tzo: None, + year: 1976, + month: 7, + day: 4, + hour: 0, + minute: 0, + second: 0, + micros: 0, + tzo: None, }; parse_and_assert_simple(pdt, "19760704"); } @@ -1173,9 +2299,14 @@ fn test_parse_simple43() { #[test] fn test_parse_simple44() { let pdt = PyDateTime { - year: 1976, month: 7, day: 4, - hour: 0, minute: 1, second: 2, - micros: 0, tzo: None, + year: 1976, + month: 7, + day: 4, + hour: 0, + minute: 1, + second: 2, + micros: 0, + tzo: None, }; parse_and_assert_simple(pdt, "0:01:02 on July 4, 1976"); } @@ -1183,9 +2314,14 @@ fn test_parse_simple44() { #[test] fn test_parse_simple45() { let pdt = PyDateTime { - year: 1976, month: 7, day: 4, - hour: 0, minute: 1, second: 2, - micros: 0, tzo: None, + year: 1976, + month: 7, + day: 4, + hour: 0, + minute: 1, + second: 2, + micros: 0, + tzo: None, }; parse_and_assert_simple(pdt, "0:01:02 on July 4, 1976"); } @@ -1193,9 +2329,14 @@ fn test_parse_simple45() { #[test] fn test_parse_simple46() { let pdt = PyDateTime { - year: 1976, month: 7, day: 4, - hour: 0, minute: 1, second: 2, - micros: 0, tzo: None, + year: 1976, + month: 7, + day: 4, + hour: 0, + minute: 1, + second: 2, + micros: 0, + tzo: None, }; parse_and_assert_simple(pdt, "July 4, 1976 12:01:02 am"); } @@ -1203,9 +2344,14 @@ fn test_parse_simple46() { #[test] fn test_parse_simple47() { let pdt = PyDateTime { - year: 1995, month: 1, day: 2, - hour: 4, minute: 24, second: 27, - micros: 0, tzo: None, + year: 1995, + month: 1, + day: 2, + hour: 4, + minute: 24, + second: 27, + micros: 0, + tzo: None, }; parse_and_assert_simple(pdt, "Mon Jan 2 04:24:27 1995"); } @@ -1213,9 +2359,14 @@ fn test_parse_simple47() { #[test] fn test_parse_simple48() { let pdt = PyDateTime { - year: 1995, month: 4, day: 4, - hour: 0, minute: 22, second: 0, - micros: 0, tzo: None, + year: 1995, + month: 4, + day: 4, + hour: 0, + minute: 22, + second: 0, + micros: 0, + tzo: None, }; parse_and_assert_simple(pdt, "04.04.95 00:22"); } @@ -1223,9 +2374,14 @@ fn test_parse_simple48() { #[test] fn test_parse_simple49() { let pdt = PyDateTime { - year: 1999, month: 1, day: 1, - hour: 11, minute: 23, second: 34, - micros: 578000, tzo: None, + year: 1999, + month: 1, + day: 1, + hour: 11, + minute: 23, + second: 34, + micros: 578000, + tzo: None, }; parse_and_assert_simple(pdt, "Jan 1 1999 11:23:34.578"); } @@ -1233,9 +2389,14 @@ fn test_parse_simple49() { #[test] fn test_parse_simple50() { let pdt = PyDateTime { - year: 1995, month: 4, day: 4, - hour: 12, minute: 22, second: 12, - micros: 0, tzo: None, + year: 1995, + month: 4, + day: 4, + hour: 12, + minute: 22, + second: 12, + micros: 0, + tzo: None, }; parse_and_assert_simple(pdt, "950404 122212"); } @@ -1243,9 +2404,14 @@ fn test_parse_simple50() { #[test] fn test_parse_simple51() { let pdt = PyDateTime { - year: 2001, month: 5, day: 3, - hour: 0, minute: 0, second: 0, - micros: 0, tzo: None, + year: 2001, + month: 5, + day: 3, + hour: 0, + minute: 0, + second: 0, + micros: 0, + tzo: None, }; parse_and_assert_simple(pdt, "3rd of May 2001"); } @@ -1253,9 +2419,14 @@ fn test_parse_simple51() { #[test] fn test_parse_simple52() { let pdt = PyDateTime { - year: 2001, month: 3, day: 5, - hour: 0, minute: 0, second: 0, - micros: 0, tzo: None, + year: 2001, + month: 3, + day: 5, + hour: 0, + minute: 0, + second: 0, + micros: 0, + tzo: None, }; parse_and_assert_simple(pdt, "5th of March 2001"); } @@ -1263,9 +2434,14 @@ fn test_parse_simple52() { #[test] fn test_parse_simple53() { let pdt = PyDateTime { - year: 2003, month: 5, day: 1, - hour: 0, minute: 0, second: 0, - micros: 0, tzo: None, + year: 2003, + month: 5, + day: 1, + hour: 0, + minute: 0, + second: 0, + micros: 0, + tzo: None, }; parse_and_assert_simple(pdt, "1st of May 2003"); } @@ -1273,9 +2449,14 @@ fn test_parse_simple53() { #[test] fn test_parse_simple54() { let pdt = PyDateTime { - year: 99, month: 1, day: 1, - hour: 0, minute: 0, second: 0, - micros: 0, tzo: None, + year: 99, + month: 1, + day: 1, + hour: 0, + minute: 0, + second: 0, + micros: 0, + tzo: None, }; parse_and_assert_simple(pdt, "0099-01-01T00:00:00"); } @@ -1283,9 +2464,14 @@ fn test_parse_simple54() { #[test] fn test_parse_simple55() { let pdt = PyDateTime { - year: 31, month: 1, day: 1, - hour: 0, minute: 0, second: 0, - micros: 0, tzo: None, + year: 31, + month: 1, + day: 1, + hour: 0, + minute: 0, + second: 0, + micros: 0, + tzo: None, }; parse_and_assert_simple(pdt, "0031-01-01T00:00:00"); } @@ -1293,9 +2479,14 @@ fn test_parse_simple55() { #[test] fn test_parse_simple56() { let pdt = PyDateTime { - year: 2008, month: 2, day: 27, - hour: 21, minute: 26, second: 1, - micros: 123456, tzo: None, + year: 2008, + month: 2, + day: 27, + hour: 21, + minute: 26, + second: 1, + micros: 123456, + tzo: None, }; parse_and_assert_simple(pdt, "20080227T21:26:01.123456789"); } @@ -1303,9 +2494,14 @@ fn test_parse_simple56() { #[test] fn test_parse_simple57() { let pdt = PyDateTime { - year: 2017, month: 11, day: 13, - hour: 0, minute: 0, second: 0, - micros: 0, tzo: None, + year: 2017, + month: 11, + day: 13, + hour: 0, + minute: 0, + second: 0, + micros: 0, + tzo: None, }; parse_and_assert_simple(pdt, "13NOV2017"); } @@ -1313,9 +2509,14 @@ fn test_parse_simple57() { #[test] fn test_parse_simple58() { let pdt = PyDateTime { - year: 3, month: 3, day: 4, - hour: 0, minute: 0, second: 0, - micros: 0, tzo: None, + year: 3, + month: 3, + day: 4, + hour: 0, + minute: 0, + second: 0, + micros: 0, + tzo: None, }; parse_and_assert_simple(pdt, "0003-03-04"); } @@ -1323,9 +2524,14 @@ fn test_parse_simple58() { #[test] fn test_parse_simple59() { let pdt = PyDateTime { - year: 31, month: 12, day: 30, - hour: 0, minute: 0, second: 0, - micros: 0, tzo: None, + year: 31, + month: 12, + day: 30, + hour: 0, + minute: 0, + second: 0, + micros: 0, + tzo: None, }; parse_and_assert_simple(pdt, "December.0031.30"); } @@ -1333,9 +2539,14 @@ fn test_parse_simple59() { #[test] fn test_parse_simple60() { let pdt = PyDateTime { - year: 2007, month: 9, day: 1, - hour: 0, minute: 0, second: 0, - micros: 0, tzo: None, + year: 2007, + month: 9, + day: 1, + hour: 0, + minute: 0, + second: 0, + micros: 0, + tzo: None, }; parse_and_assert_simple(pdt, "090107"); } @@ -1343,9 +2554,14 @@ fn test_parse_simple60() { #[test] fn test_parse_simple61() { let pdt = PyDateTime { - year: 2015, month: 5, day: 15, - hour: 0, minute: 0, second: 0, - micros: 0, tzo: None, + year: 2015, + month: 5, + day: 15, + hour: 0, + minute: 0, + second: 0, + micros: 0, + tzo: None, }; parse_and_assert_simple(pdt, "2015-15-May"); } @@ -1354,530 +2570,1213 @@ fn test_parse_simple61() { fn test_parse_tzinfo0() { let info = ParserInfo::default(); let pdt = PyDateTime { - year: 2003, month: 9, day: 25, - hour: 10, minute: 36, second: 28, - micros: 0, tzo: Some(-10800), + year: 2003, + month: 9, + day: 25, + hour: 10, + minute: 36, + second: 28, + micros: 0, + tzo: Some(-10800), }; - parse_and_assert(pdt, info, "Thu Sep 25 10:36:28 BRST 2003", None, None, false, false, - None, false, &rs_tzinfo_map!()); + parse_and_assert( + pdt, + info, + "Thu Sep 25 10:36:28 BRST 2003", + None, + None, + false, + false, + None, + false, + &rs_tzinfo_map!(), + ); } #[test] fn test_parse_tzinfo1() { let info = ParserInfo::default(); let pdt = PyDateTime { - year: 2003, month: 9, day: 25, - hour: 10, minute: 36, second: 28, - micros: 0, tzo: Some(-10800), + year: 2003, + month: 9, + day: 25, + hour: 10, + minute: 36, + second: 28, + micros: 0, + tzo: Some(-10800), }; - parse_and_assert(pdt, info, "2003 10:36:28 BRST 25 Sep Thu", None, None, false, false, - None, false, &rs_tzinfo_map!()); + parse_and_assert( + pdt, + info, + "2003 10:36:28 BRST 25 Sep Thu", + None, + None, + false, + false, + None, + false, + &rs_tzinfo_map!(), + ); } #[test] fn test_parse_offset0() { let info = ParserInfo::default(); let pdt = PyDateTime { - year: 2003, month: 9, day: 25, - hour: 10, minute: 49, second: 41, - micros: 0, tzo: Some(-10800), + year: 2003, + month: 9, + day: 25, + hour: 10, + minute: 49, + second: 41, + micros: 0, + tzo: Some(-10800), }; - parse_and_assert(pdt, info, "Thu, 25 Sep 2003 10:49:41 -0300", None, None, false, false, - None, false, &HashMap::new()); + parse_and_assert( + pdt, + info, + "Thu, 25 Sep 2003 10:49:41 -0300", + None, + None, + false, + false, + None, + false, + &HashMap::new(), + ); } #[test] fn test_parse_offset1() { let info = ParserInfo::default(); let pdt = PyDateTime { - year: 2003, month: 9, day: 25, - hour: 10, minute: 49, second: 41, - micros: 500000, tzo: Some(-10800), + year: 2003, + month: 9, + day: 25, + hour: 10, + minute: 49, + second: 41, + micros: 500000, + tzo: Some(-10800), }; - parse_and_assert(pdt, info, "2003-09-25T10:49:41.5-03:00", None, None, false, false, - None, false, &HashMap::new()); + parse_and_assert( + pdt, + info, + "2003-09-25T10:49:41.5-03:00", + None, + None, + false, + false, + None, + false, + &HashMap::new(), + ); } #[test] fn test_parse_offset2() { let info = ParserInfo::default(); let pdt = PyDateTime { - year: 2003, month: 9, day: 25, - hour: 10, minute: 49, second: 41, - micros: 0, tzo: Some(-10800), + year: 2003, + month: 9, + day: 25, + hour: 10, + minute: 49, + second: 41, + micros: 0, + tzo: Some(-10800), }; - parse_and_assert(pdt, info, "2003-09-25T10:49:41-03:00", None, None, false, false, - None, false, &HashMap::new()); + parse_and_assert( + pdt, + info, + "2003-09-25T10:49:41-03:00", + None, + None, + false, + false, + None, + false, + &HashMap::new(), + ); } #[test] fn test_parse_offset3() { let info = ParserInfo::default(); let pdt = PyDateTime { - year: 2003, month: 9, day: 25, - hour: 10, minute: 49, second: 41, - micros: 500000, tzo: Some(-10800), + year: 2003, + month: 9, + day: 25, + hour: 10, + minute: 49, + second: 41, + micros: 500000, + tzo: Some(-10800), }; - parse_and_assert(pdt, info, "20030925T104941.5-0300", None, None, false, false, - None, false, &HashMap::new()); + parse_and_assert( + pdt, + info, + "20030925T104941.5-0300", + None, + None, + false, + false, + None, + false, + &HashMap::new(), + ); } #[test] fn test_parse_offset4() { let info = ParserInfo::default(); let pdt = PyDateTime { - year: 2003, month: 9, day: 25, - hour: 10, minute: 49, second: 41, - micros: 0, tzo: Some(-10800), + year: 2003, + month: 9, + day: 25, + hour: 10, + minute: 49, + second: 41, + micros: 0, + tzo: Some(-10800), }; - parse_and_assert(pdt, info, "20030925T104941-0300", None, None, false, false, - None, false, &HashMap::new()); + parse_and_assert( + pdt, + info, + "20030925T104941-0300", + None, + None, + false, + false, + None, + false, + &HashMap::new(), + ); } #[test] fn test_parse_offset5() { let info = ParserInfo::default(); let pdt = PyDateTime { - year: 2018, month: 8, day: 10, - hour: 10, minute: 0, second: 0, - micros: 0, tzo: Some(-10800), + year: 2018, + month: 8, + day: 10, + hour: 10, + minute: 0, + second: 0, + micros: 0, + tzo: Some(-10800), }; - parse_and_assert(pdt, info, "2018-08-10 10:00:00 UTC+3", None, None, false, false, - None, false, &HashMap::new()); + parse_and_assert( + pdt, + info, + "2018-08-10 10:00:00 UTC+3", + None, + None, + false, + false, + None, + false, + &HashMap::new(), + ); } #[test] fn test_parse_offset6() { let info = ParserInfo::default(); let pdt = PyDateTime { - year: 2018, month: 8, day: 10, - hour: 15, minute: 36, second: 47, - micros: 0, tzo: Some(14400), + year: 2018, + month: 8, + day: 10, + hour: 15, + minute: 36, + second: 47, + micros: 0, + tzo: Some(14400), }; - parse_and_assert(pdt, info, "2018-08-10 03:36:47 PM GMT-4", None, None, false, false, - None, false, &HashMap::new()); + parse_and_assert( + pdt, + info, + "2018-08-10 03:36:47 PM GMT-4", + None, + None, + false, + false, + None, + false, + &HashMap::new(), + ); } #[test] fn test_parse_offset7() { let info = ParserInfo::default(); let pdt = PyDateTime { - year: 2018, month: 8, day: 10, - hour: 4, minute: 15, second: 0, - micros: 0, tzo: Some(7200), + year: 2018, + month: 8, + day: 10, + hour: 4, + minute: 15, + second: 0, + micros: 0, + tzo: Some(7200), }; - parse_and_assert(pdt, info, "2018-08-10 04:15:00 AM Z-02:00", None, None, false, false, - None, false, &HashMap::new()); + parse_and_assert( + pdt, + info, + "2018-08-10 04:15:00 AM Z-02:00", + None, + None, + false, + false, + None, + false, + &HashMap::new(), + ); } #[test] fn test_parse_dayfirst0() { let info = ParserInfo::default(); let pdt = PyDateTime { - year: 2003, month: 9, day: 10, - hour: 0, minute: 0, second: 0, - micros: 0, tzo: None, + year: 2003, + month: 9, + day: 10, + hour: 0, + minute: 0, + second: 0, + micros: 0, + tzo: None, }; - parse_and_assert(pdt, info, "10-09-2003", Some(true), None, false, false, - None, false, &HashMap::new()); + parse_and_assert( + pdt, + info, + "10-09-2003", + Some(true), + None, + false, + false, + None, + false, + &HashMap::new(), + ); } #[test] fn test_parse_dayfirst1() { let info = ParserInfo::default(); let pdt = PyDateTime { - year: 2003, month: 9, day: 10, - hour: 0, minute: 0, second: 0, - micros: 0, tzo: None, + year: 2003, + month: 9, + day: 10, + hour: 0, + minute: 0, + second: 0, + micros: 0, + tzo: None, }; - parse_and_assert(pdt, info, "10.09.2003", Some(true), None, false, false, - None, false, &HashMap::new()); + parse_and_assert( + pdt, + info, + "10.09.2003", + Some(true), + None, + false, + false, + None, + false, + &HashMap::new(), + ); } #[test] fn test_parse_dayfirst2() { let info = ParserInfo::default(); let pdt = PyDateTime { - year: 2003, month: 9, day: 10, - hour: 0, minute: 0, second: 0, - micros: 0, tzo: None, + year: 2003, + month: 9, + day: 10, + hour: 0, + minute: 0, + second: 0, + micros: 0, + tzo: None, }; - parse_and_assert(pdt, info, "10/09/2003", Some(true), None, false, false, - None, false, &HashMap::new()); + parse_and_assert( + pdt, + info, + "10/09/2003", + Some(true), + None, + false, + false, + None, + false, + &HashMap::new(), + ); } #[test] fn test_parse_dayfirst3() { let info = ParserInfo::default(); let pdt = PyDateTime { - year: 2003, month: 9, day: 10, - hour: 0, minute: 0, second: 0, - micros: 0, tzo: None, + year: 2003, + month: 9, + day: 10, + hour: 0, + minute: 0, + second: 0, + micros: 0, + tzo: None, }; - parse_and_assert(pdt, info, "10 09 2003", Some(true), None, false, false, - None, false, &HashMap::new()); + parse_and_assert( + pdt, + info, + "10 09 2003", + Some(true), + None, + false, + false, + None, + false, + &HashMap::new(), + ); } #[test] fn test_parse_dayfirst4() { let info = ParserInfo::default(); let pdt = PyDateTime { - year: 2007, month: 1, day: 9, - hour: 0, minute: 0, second: 0, - micros: 0, tzo: None, + year: 2007, + month: 1, + day: 9, + hour: 0, + minute: 0, + second: 0, + micros: 0, + tzo: None, }; - parse_and_assert(pdt, info, "090107", Some(true), None, false, false, - None, false, &HashMap::new()); + parse_and_assert( + pdt, + info, + "090107", + Some(true), + None, + false, + false, + None, + false, + &HashMap::new(), + ); } #[test] fn test_parse_dayfirst5() { let info = ParserInfo::default(); let pdt = PyDateTime { - year: 2015, month: 9, day: 25, - hour: 0, minute: 0, second: 0, - micros: 0, tzo: None, + year: 2015, + month: 9, + day: 25, + hour: 0, + minute: 0, + second: 0, + micros: 0, + tzo: None, }; - parse_and_assert(pdt, info, "2015 09 25", Some(true), None, false, false, - None, false, &HashMap::new()); + parse_and_assert( + pdt, + info, + "2015 09 25", + Some(true), + None, + false, + false, + None, + false, + &HashMap::new(), + ); } #[test] fn test_parse_yearfirst0() { let info = ParserInfo::default(); let pdt = PyDateTime { - year: 2010, month: 9, day: 3, - hour: 0, minute: 0, second: 0, - micros: 0, tzo: None, + year: 2010, + month: 9, + day: 3, + hour: 0, + minute: 0, + second: 0, + micros: 0, + tzo: None, }; - parse_and_assert(pdt, info, "10-09-03", None, Some(true), false, false, - None, false, &HashMap::new()); + parse_and_assert( + pdt, + info, + "10-09-03", + None, + Some(true), + false, + false, + None, + false, + &HashMap::new(), + ); } #[test] fn test_parse_yearfirst1() { let info = ParserInfo::default(); let pdt = PyDateTime { - year: 2010, month: 9, day: 3, - hour: 0, minute: 0, second: 0, - micros: 0, tzo: None, + year: 2010, + month: 9, + day: 3, + hour: 0, + minute: 0, + second: 0, + micros: 0, + tzo: None, }; - parse_and_assert(pdt, info, "10.09.03", None, Some(true), false, false, - None, false, &HashMap::new()); + parse_and_assert( + pdt, + info, + "10.09.03", + None, + Some(true), + false, + false, + None, + false, + &HashMap::new(), + ); } #[test] fn test_parse_yearfirst2() { let info = ParserInfo::default(); let pdt = PyDateTime { - year: 2010, month: 9, day: 3, - hour: 0, minute: 0, second: 0, - micros: 0, tzo: None, + year: 2010, + month: 9, + day: 3, + hour: 0, + minute: 0, + second: 0, + micros: 0, + tzo: None, }; - parse_and_assert(pdt, info, "10/09/03", None, Some(true), false, false, - None, false, &HashMap::new()); + parse_and_assert( + pdt, + info, + "10/09/03", + None, + Some(true), + false, + false, + None, + false, + &HashMap::new(), + ); } #[test] fn test_parse_yearfirst3() { let info = ParserInfo::default(); let pdt = PyDateTime { - year: 2010, month: 9, day: 3, - hour: 0, minute: 0, second: 0, - micros: 0, tzo: None, + year: 2010, + month: 9, + day: 3, + hour: 0, + minute: 0, + second: 0, + micros: 0, + tzo: None, }; - parse_and_assert(pdt, info, "10 09 03", None, Some(true), false, false, - None, false, &HashMap::new()); + parse_and_assert( + pdt, + info, + "10 09 03", + None, + Some(true), + false, + false, + None, + false, + &HashMap::new(), + ); } #[test] fn test_parse_yearfirst4() { let info = ParserInfo::default(); let pdt = PyDateTime { - year: 2009, month: 1, day: 7, - hour: 0, minute: 0, second: 0, - micros: 0, tzo: None, + year: 2009, + month: 1, + day: 7, + hour: 0, + minute: 0, + second: 0, + micros: 0, + tzo: None, }; - parse_and_assert(pdt, info, "090107", None, Some(true), false, false, - None, false, &HashMap::new()); + parse_and_assert( + pdt, + info, + "090107", + None, + Some(true), + false, + false, + None, + false, + &HashMap::new(), + ); } #[test] fn test_parse_yearfirst5() { let info = ParserInfo::default(); let pdt = PyDateTime { - year: 2015, month: 9, day: 25, - hour: 0, minute: 0, second: 0, - micros: 0, tzo: None, + year: 2015, + month: 9, + day: 25, + hour: 0, + minute: 0, + second: 0, + micros: 0, + tzo: None, }; - parse_and_assert(pdt, info, "2015 09 25", None, Some(true), false, false, - None, false, &HashMap::new()); + parse_and_assert( + pdt, + info, + "2015 09 25", + None, + Some(true), + false, + false, + None, + false, + &HashMap::new(), + ); } #[test] fn test_parse_dfyf0() { let info = ParserInfo::default(); let pdt = PyDateTime { - year: 2009, month: 7, day: 1, - hour: 0, minute: 0, second: 0, - micros: 0, tzo: None, + year: 2009, + month: 7, + day: 1, + hour: 0, + minute: 0, + second: 0, + micros: 0, + tzo: None, }; - parse_and_assert(pdt, info, "090107", Some(true), Some(true), false, false, - None, false, &HashMap::new()); + parse_and_assert( + pdt, + info, + "090107", + Some(true), + Some(true), + false, + false, + None, + false, + &HashMap::new(), + ); } #[test] fn test_parse_dfyf1() { let info = ParserInfo::default(); let pdt = PyDateTime { - year: 2015, month: 9, day: 25, - hour: 0, minute: 0, second: 0, - micros: 0, tzo: None, + year: 2015, + month: 9, + day: 25, + hour: 0, + minute: 0, + second: 0, + micros: 0, + tzo: None, }; - parse_and_assert(pdt, info, "2015 09 25", Some(true), Some(true), false, false, - None, false, &HashMap::new()); + parse_and_assert( + pdt, + info, + "2015 09 25", + Some(true), + Some(true), + false, + false, + None, + false, + &HashMap::new(), + ); } #[test] fn test_unspecified_fallback0() { let info = ParserInfo::default(); - let default_rsdate = &NaiveDate::from_ymd_opt(2010, 1, 31).unwrap().and_hms_opt(0, 0, 0).unwrap(); + let default_rsdate = &NaiveDate::from_ymd_opt(2010, 1, 31) + .unwrap() + .and_hms_opt(0, 0, 0) + .unwrap(); let pdt = PyDateTime { - year: 2009, month: 4, day: 30, - hour: 0, minute: 0, second: 0, - micros: 0, tzo: None + year: 2009, + month: 4, + day: 30, + hour: 0, + minute: 0, + second: 0, + micros: 0, + tzo: None, }; - parse_and_assert(pdt, info, "April 2009", None, None, false, false, - Some(default_rsdate), false, &HashMap::new()); + parse_and_assert( + pdt, + info, + "April 2009", + None, + None, + false, + false, + Some(default_rsdate), + false, + &HashMap::new(), + ); } #[test] fn test_unspecified_fallback1() { let info = ParserInfo::default(); - let default_rsdate = &NaiveDate::from_ymd_opt(2010, 1, 31).unwrap().and_hms_opt(0, 0, 0).unwrap(); + let default_rsdate = &NaiveDate::from_ymd_opt(2010, 1, 31) + .unwrap() + .and_hms_opt(0, 0, 0) + .unwrap(); let pdt = PyDateTime { - year: 2007, month: 2, day: 28, - hour: 0, minute: 0, second: 0, - micros: 0, tzo: None + year: 2007, + month: 2, + day: 28, + hour: 0, + minute: 0, + second: 0, + micros: 0, + tzo: None, }; - parse_and_assert(pdt, info, "Feb 2007", None, None, false, false, - Some(default_rsdate), false, &HashMap::new()); + parse_and_assert( + pdt, + info, + "Feb 2007", + None, + None, + false, + false, + Some(default_rsdate), + false, + &HashMap::new(), + ); } #[test] fn test_unspecified_fallback2() { let info = ParserInfo::default(); - let default_rsdate = &NaiveDate::from_ymd_opt(2010, 1, 31).unwrap().and_hms_opt(0, 0, 0).unwrap(); + let default_rsdate = &NaiveDate::from_ymd_opt(2010, 1, 31) + .unwrap() + .and_hms_opt(0, 0, 0) + .unwrap(); let pdt = PyDateTime { - year: 2008, month: 2, day: 29, - hour: 0, minute: 0, second: 0, - micros: 0, tzo: None + year: 2008, + month: 2, + day: 29, + hour: 0, + minute: 0, + second: 0, + micros: 0, + tzo: None, }; - parse_and_assert(pdt, info, "Feb 2008", None, None, false, false, - Some(default_rsdate), false, &HashMap::new()); + parse_and_assert( + pdt, + info, + "Feb 2008", + None, + None, + false, + false, + Some(default_rsdate), + false, + &HashMap::new(), + ); } #[test] fn test_parse_ignoretz0() { let info = ParserInfo::default(); let pdt = PyDateTime { - year: 2003, month: 9, day: 25, - hour: 10, minute: 36, second: 28, - micros: 0, tzo: None + year: 2003, + month: 9, + day: 25, + hour: 10, + minute: 36, + second: 28, + micros: 0, + tzo: None, }; - parse_and_assert(pdt, info, "Thu Sep 25 10:36:28 BRST 2003", None, None, false, false, - None, true, &HashMap::new()); + parse_and_assert( + pdt, + info, + "Thu Sep 25 10:36:28 BRST 2003", + None, + None, + false, + false, + None, + true, + &HashMap::new(), + ); } #[test] fn test_parse_ignoretz1() { let info = ParserInfo::default(); let pdt = PyDateTime { - year: 1996, month: 7, day: 10, - hour: 15, minute: 8, second: 56, - micros: 0, tzo: None + year: 1996, + month: 7, + day: 10, + hour: 15, + minute: 8, + second: 56, + micros: 0, + tzo: None, }; - parse_and_assert(pdt, info, "1996.07.10 AD at 15:08:56 PDT", None, None, false, false, - None, true, &HashMap::new()); + parse_and_assert( + pdt, + info, + "1996.07.10 AD at 15:08:56 PDT", + None, + None, + false, + false, + None, + true, + &HashMap::new(), + ); } #[test] fn test_parse_ignoretz2() { let info = ParserInfo::default(); let pdt = PyDateTime { - year: 1952, month: 4, day: 12, - hour: 15, minute: 30, second: 42, - micros: 0, tzo: None + year: 1952, + month: 4, + day: 12, + hour: 15, + minute: 30, + second: 42, + micros: 0, + tzo: None, }; - parse_and_assert(pdt, info, "Tuesday, April 12, 1952 AD 3:30:42pm PST", None, None, false, false, - None, true, &HashMap::new()); + parse_and_assert( + pdt, + info, + "Tuesday, April 12, 1952 AD 3:30:42pm PST", + None, + None, + false, + false, + None, + true, + &HashMap::new(), + ); } #[test] fn test_parse_ignoretz3() { let info = ParserInfo::default(); let pdt = PyDateTime { - year: 1994, month: 11, day: 5, - hour: 8, minute: 15, second: 30, - micros: 0, tzo: None + year: 1994, + month: 11, + day: 5, + hour: 8, + minute: 15, + second: 30, + micros: 0, + tzo: None, }; - parse_and_assert(pdt, info, "November 5, 1994, 8:15:30 am EST", None, None, false, false, - None, true, &HashMap::new()); + parse_and_assert( + pdt, + info, + "November 5, 1994, 8:15:30 am EST", + None, + None, + false, + false, + None, + true, + &HashMap::new(), + ); } #[test] fn test_parse_ignoretz4() { let info = ParserInfo::default(); let pdt = PyDateTime { - year: 1994, month: 11, day: 5, - hour: 8, minute: 15, second: 30, - micros: 0, tzo: None + year: 1994, + month: 11, + day: 5, + hour: 8, + minute: 15, + second: 30, + micros: 0, + tzo: None, }; - parse_and_assert(pdt, info, "1994-11-05T08:15:30-05:00", None, None, false, false, - None, true, &HashMap::new()); + parse_and_assert( + pdt, + info, + "1994-11-05T08:15:30-05:00", + None, + None, + false, + false, + None, + true, + &HashMap::new(), + ); } #[test] fn test_parse_ignoretz5() { let info = ParserInfo::default(); let pdt = PyDateTime { - year: 1994, month: 11, day: 5, - hour: 8, minute: 15, second: 30, - micros: 0, tzo: None + year: 1994, + month: 11, + day: 5, + hour: 8, + minute: 15, + second: 30, + micros: 0, + tzo: None, }; - parse_and_assert(pdt, info, "1994-11-05T08:15:30Z", None, None, false, false, - None, true, &HashMap::new()); + parse_and_assert( + pdt, + info, + "1994-11-05T08:15:30Z", + None, + None, + false, + false, + None, + true, + &HashMap::new(), + ); } #[test] fn test_parse_ignoretz6() { let info = ParserInfo::default(); let pdt = PyDateTime { - year: 1976, month: 7, day: 4, - hour: 0, minute: 1, second: 2, - micros: 0, tzo: None + year: 1976, + month: 7, + day: 4, + hour: 0, + minute: 1, + second: 2, + micros: 0, + tzo: None, }; - parse_and_assert(pdt, info, "1976-07-04T00:01:02Z", None, None, false, false, - None, true, &HashMap::new()); + parse_and_assert( + pdt, + info, + "1976-07-04T00:01:02Z", + None, + None, + false, + false, + None, + true, + &HashMap::new(), + ); } #[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 + 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()); + 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, month: 4, day: 4, - hour: 0, minute: 22, second: 12, - micros: 0, tzo: None + year: 1995, + month: 4, + day: 4, + hour: 0, + minute: 22, + second: 12, + micros: 0, + tzo: None, }; - parse_and_assert(pdt, info, "Tue Apr 4 00:22:12 PDT 1995", None, None, false, false, - None, true, &HashMap::new()); + parse_and_assert( + pdt, + info, + "Tue Apr 4 00:22:12 PDT 1995", + None, + None, + false, + false, + None, + true, + &HashMap::new(), + ); } #[test] fn test_fuzzy_tzinfo0() { let info = ParserInfo::default(); let pdt = PyDateTime { - year: 2003, month: 9, day: 25, - hour: 10, minute: 49, second: 41, - micros: 0, tzo: Some(-10800) + year: 2003, + month: 9, + day: 25, + hour: 10, + minute: 49, + second: 41, + micros: 0, + tzo: Some(-10800), }; - parse_fuzzy_and_assert(pdt, None, info, "Today is 25 of September of 2003, exactly at 10:49:41 with timezone -03:00.", None, None, true, false, - None, false, &HashMap::new()); + parse_fuzzy_and_assert( + pdt, + None, + info, + "Today is 25 of September of 2003, exactly at 10:49:41 with timezone -03:00.", + None, + None, + true, + false, + None, + false, + &HashMap::new(), + ); } #[test] fn test_fuzzy_tokens_tzinfo0() { let info = ParserInfo::default(); let pdt = PyDateTime { - year: 2003, month: 9, day: 25, - hour: 10, minute: 49, second: 41, - micros: 0, tzo: Some(-10800) + year: 2003, + month: 9, + day: 25, + hour: 10, + minute: 49, + second: 41, + micros: 0, + tzo: Some(-10800), }; - let tokens = vec!["Today is ".to_owned(), "of ".to_owned(), ", exactly at ".to_owned(), " with timezone ".to_owned(), ".".to_owned()]; - parse_fuzzy_and_assert(pdt, Some(tokens), info, "Today is 25 of September of 2003, exactly at 10:49:41 with timezone -03:00.", None, None, true, true, - None, false, &HashMap::new()); + let tokens = vec![ + "Today is ".to_owned(), + "of ".to_owned(), + ", exactly at ".to_owned(), + " with timezone ".to_owned(), + ".".to_owned(), + ]; + parse_fuzzy_and_assert( + pdt, + Some(tokens), + info, + "Today is 25 of September of 2003, exactly at 10:49:41 with timezone -03:00.", + None, + None, + true, + true, + None, + false, + &HashMap::new(), + ); } #[test] fn test_fuzzy_simple0() { let info = ParserInfo::default(); let pdt = PyDateTime { - year: 1974, month: 3, day: 1, - hour: 0, minute: 0, second: 0, - micros: 0, tzo: None + year: 1974, + month: 3, + day: 1, + hour: 0, + minute: 0, + second: 0, + micros: 0, + tzo: None, }; - parse_fuzzy_and_assert(pdt, None, info, "I have a meeting on March 1, 1974", None, None, true, false, - None, false, &HashMap::new()); + parse_fuzzy_and_assert( + pdt, + None, + info, + "I have a meeting on March 1, 1974", + None, + None, + true, + false, + None, + false, + &HashMap::new(), + ); } #[test] fn test_fuzzy_simple1() { let info = ParserInfo::default(); let pdt = PyDateTime { - year: 2020, month: 6, day: 8, - hour: 0, minute: 0, second: 0, - micros: 0, tzo: None + year: 2020, + month: 6, + day: 8, + hour: 0, + minute: 0, + second: 0, + micros: 0, + tzo: None, }; - parse_fuzzy_and_assert(pdt, None, info, "On June 8th, 2020, I am going to be the first man on Mars", None, None, true, false, - None, false, &HashMap::new()); + parse_fuzzy_and_assert( + pdt, + None, + info, + "On June 8th, 2020, I am going to be the first man on Mars", + None, + None, + true, + false, + None, + false, + &HashMap::new(), + ); } #[test] fn test_fuzzy_simple2() { let info = ParserInfo::default(); let pdt = PyDateTime { - year: 2003, month: 12, day: 3, - hour: 3, minute: 0, second: 0, - micros: 0, tzo: None + year: 2003, + month: 12, + day: 3, + hour: 3, + minute: 0, + second: 0, + micros: 0, + tzo: None, }; - parse_fuzzy_and_assert(pdt, None, info, "Meet me at the AM/PM on Sunset at 3:00 AM on December 3rd, 2003", None, None, true, false, - None, false, &HashMap::new()); + parse_fuzzy_and_assert( + pdt, + None, + info, + "Meet me at the AM/PM on Sunset at 3:00 AM on December 3rd, 2003", + None, + None, + true, + false, + None, + false, + &HashMap::new(), + ); } #[test] fn test_fuzzy_simple3() { let info = ParserInfo::default(); let pdt = PyDateTime { - year: 2003, month: 12, day: 3, - hour: 3, minute: 0, second: 0, - micros: 0, tzo: None + year: 2003, + month: 12, + day: 3, + hour: 3, + minute: 0, + second: 0, + micros: 0, + tzo: None, }; - parse_fuzzy_and_assert(pdt, None, info, "Meet me at 3:00 AM on December 3rd, 2003 at the AM/PM on Sunset", None, None, true, false, - None, false, &HashMap::new()); + parse_fuzzy_and_assert( + pdt, + None, + info, + "Meet me at 3:00 AM on December 3rd, 2003 at the AM/PM on Sunset", + None, + None, + true, + false, + None, + false, + &HashMap::new(), + ); } #[test] fn test_fuzzy_simple4() { let info = ParserInfo::default(); let pdt = PyDateTime { - year: 1945, month: 1, day: 29, - hour: 14, minute: 45, second: 0, - micros: 0, tzo: None + year: 1945, + month: 1, + day: 29, + hour: 14, + minute: 45, + second: 0, + micros: 0, + tzo: None, }; - parse_fuzzy_and_assert(pdt, None, info, "Jan 29, 1945 14:45 AM I going to see you there?", None, None, true, false, - None, false, &HashMap::new()); + parse_fuzzy_and_assert( + pdt, + None, + info, + "Jan 29, 1945 14:45 AM I going to see you there?", + None, + None, + true, + false, + None, + false, + &HashMap::new(), + ); } #[test] fn test_fuzzy_simple5() { let info = ParserInfo::default(); let pdt = PyDateTime { - year: 2017, month: 7, day: 17, - hour: 6, minute: 15, second: 0, - micros: 0, tzo: None + year: 2017, + month: 7, + day: 17, + hour: 6, + minute: 15, + second: 0, + micros: 0, + tzo: None, }; - parse_fuzzy_and_assert(pdt, None, info, "2017-07-17 06:15:", None, None, true, false, - None, false, &HashMap::new()); + parse_fuzzy_and_assert( + pdt, + None, + info, + "2017-07-17 06:15:", + None, + None, + true, + false, + None, + false, + &HashMap::new(), + ); }