From 6953afb5e2452e290bcdd926a01101155d55d35e Mon Sep 17 00:00:00 2001 From: 007gzs <007gzs@gmail.com> Date: Tue, 3 Sep 2024 15:10:46 +0800 Subject: [PATCH] unwrap --- examples/russian.rs | 5 +- src/lib.rs | 145 +- src/tests/fuzzing.rs | 21 +- src/tests/mod.rs | 12 +- src/tests/pycompat_parser.rs | 3365 ++++++++++++++++++++++++++-------- src/weekday.rs | 2 +- 6 files changed, 2738 insertions(+), 812 deletions(-) diff --git a/examples/russian.rs b/examples/russian.rs index da03116..b50a688 100644 --- a/examples/russian.rs +++ b/examples/russian.rs @@ -43,6 +43,9 @@ fn main() { ) .unwrap() .0, - NaiveDate::from_ymd_opt(2015, 9, 10).unwrap().and_hms_opt(10, 20, 0).unwrap() + NaiveDate::from_ymd_opt(2015, 9, 10) + .unwrap() + .and_hms_opt(10, 20, 0) + .unwrap() ); } diff --git a/src/lib.rs b/src/lib.rs index 8a9e717..039acf3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -151,6 +151,8 @@ pub enum ParseError { YearMonthDayError(&'static str), /// Parser unable to find any date/time-related content in the supplied string NoDate, + /// need Some but got None + System, } impl fmt::Display for ParseError { @@ -305,13 +307,7 @@ impl ParserInfo { } fn ampm_index(&self, name: &str) -> Option { - if let Some(v) = self.ampm.get(&name.to_lowercase()) { - // Python technically uses numbers here, but given that the numbers are - // only 0 and 1, it's easier to use booleans - Some(*v == 1) - } else { - None - } + self.ampm.get(&name.to_lowercase()).map(|v| *v == 1) } fn pertain_index(&self, name: &str) -> bool { @@ -367,6 +363,12 @@ impl ParserInfo { } } +fn option_to_result(opt: Option) -> Result { + match opt { + Some(v) => Ok(v), + None => Err(ParseError::System), + } +} fn days_in_month(year: i32, month: i32) -> Result { let leap_year = match year % 4 { 0 => year % 400 != 0, @@ -412,7 +414,7 @@ impl YMD { if self.dstridx.is_some() { false } else if self.mstridx.is_none() { - (1 <= val) && (val <= 31) + (1..=31).contains(&val) } else if self.ystridx.is_none() { // UNWRAP: Earlier condition catches mstridx missing let month = self._ymd[self.mstridx.unwrap()]; @@ -715,7 +717,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)?; @@ -758,7 +761,7 @@ impl Parser { let mut res = ParsingResult::default(); - let mut l = tokenize(×tr); + let mut l = tokenize(timestr); let mut skipped_idxs: Vec = Vec::new(); let mut ymd = YMD::default(); @@ -814,9 +817,8 @@ impl Parser { skipped_idxs.push(i); } } else if self.could_be_tzname(res.hour, &res.tzname, res.tzoffset, &l[i]) { - res.tzname = Some(l[i].clone()); - - let tzname = res.tzname.clone().unwrap(); + let tzname = l[i].clone(); + res.tzname = Some(tzname.clone()); res.tzoffset = self.info.tzoffset_index(&tzname).map(|t| t as i32); if i + 1 < len_l && (l[i + 1] == "+" || l[i + 1] == "-") { @@ -861,9 +863,9 @@ impl Parser { hour_offset = Some(l[i + 1][..range_len].parse::()?); min_offset = Some(0); } - - res.tzoffset = - Some(signal * (hour_offset.unwrap() * 3600 + min_offset.unwrap() * 60)); + if let (Some(hour_offset), Some(min_offset)) = (hour_offset, min_offset) { + res.tzoffset = Some(signal * (hour_offset * 3600 + min_offset * 60)); + } let tzname = res.tzname.clone(); if i + 5 < len_l @@ -923,21 +925,24 @@ impl Parser { && (all_ascii_upper || self.info.utczone.contains_key(token)) } - #[allow(clippy::unnecessary_unwrap)] fn ampm_valid(&self, hour: Option, ampm: Option, fuzzy: bool) -> ParseResult { let mut val_is_ampm = !(fuzzy && ampm.is_some()); - - if hour.is_none() { - if fuzzy { - val_is_ampm = false; - } else { - return Err(ParseError::AmPmWithoutHour); + match hour { + Some(hour) => { + if !(0..=12).contains(&hour) { + if fuzzy { + val_is_ampm = false; + } else { + return Err(ParseError::ImpossibleTimestamp("Invalid hour")); + } + } } - } else if !(0 <= hour.unwrap() && hour.unwrap() <= 12) { - if fuzzy { - val_is_ampm = false; - } else { - return Err(ParseError::ImpossibleTimestamp("Invalid hour")); + None => { + if fuzzy { + val_is_ampm = false; + } else { + return Err(ParseError::AmPmWithoutHour); + } } } @@ -951,12 +956,9 @@ impl Parser { ) -> ParseResult { let y = res.year.unwrap_or_else(|| default.year()); let m = res.month.unwrap_or_else(|| default.month() as i32) as u32; - - let d_offset = if res.weekday.is_some() && res.day.is_none() { + let d_offset = if let (Some(weekday), None) = (res.weekday, res.day) { let dow = day_of_week(y as u32, m, default.day())?; - - // UNWRAP: We've already check res.weekday() is some - let actual_weekday = (res.weekday.unwrap() + 1) % 7; + let actual_weekday = (weekday + 1) % 7; let other = DayOfWeek::from_numeral(actual_weekday as u32); Duration::days(i64::from(dow.difference(&other))) } else { @@ -972,16 +974,16 @@ impl Parser { days_in_month(y, m as i32)?, ), ) - .ok_or_else(|| ParseError::ImpossibleTimestamp("Invalid date range given"))?; + .ok_or(ParseError::ImpossibleTimestamp("Invalid date range given"))?; let d = d + d_offset; 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 { @@ -1008,11 +1010,11 @@ impl Parser { ) -> ParseResult> { if let Some(offset) = res.tzoffset { Ok(FixedOffset::east_opt(offset)) - } else if res.tzoffset == None + } else if res.tzoffset.is_none() && (res.tzname == Some(" ".to_owned()) || res.tzname == Some(".".to_owned()) || res.tzname == Some("-".to_owned()) - || res.tzname == None) + || res.tzname.is_none()) { Ok(None) } else if res.tzname.is_some() && tzinfos.contains_key(res.tzname.as_ref().unwrap()) { @@ -1027,7 +1029,6 @@ impl Parser { } } - #[allow(clippy::unnecessary_unwrap)] fn parse_numeric_token( &self, tokens: &[String], @@ -1039,7 +1040,7 @@ impl Parser { ) -> ParseResult { let mut idx = idx; let value_repr = &tokens[idx]; - let mut value = Decimal::from_str(&value_repr).unwrap(); + let mut value = Decimal::from_str(value_repr)?; let len_li = value_repr.len(); let len_l = tokens.len(); @@ -1063,7 +1064,7 @@ impl Parser { // YYMMDD or HHMMSS[.ss] let s = &tokens[idx]; - if ymd.len() == 0 && tokens[idx].find('.') == None { + if ymd.len() == 0 && tokens[idx].find('.').is_none() { ymd.append(s[0..2].parse::()?, &s[0..2], None)?; ymd.append(s[2..4].parse::()?, &s[2..4], None)?; ymd.append(s[4..6].parse::()?, &s[4..6], None)?; @@ -1076,7 +1077,7 @@ impl Parser { res.second = Some(t.0); res.nanosecond = Some(t.1); } - } else if vec![8, 12, 14].contains(&len_li) { + } else if [8, 12, 14].contains(&len_li) { // YYMMDD let s = &tokens[idx]; ymd.append(s[..4].parse::()?, &s[..4], Some(YMDLabel::Year))?; @@ -1101,7 +1102,9 @@ impl Parser { } else if idx + 2 < len_l && tokens[idx + 1] == ":" { // HH:MM[:SS[.ss]] // TODO: Better story around Decimal handling - res.hour = Some(value.floor().to_i64().unwrap() as i32); + if let Some(v) = value.floor().to_i64() { + res.hour = Some(v as i32); + } // TODO: Rescope `value` here? value = self.to_decimal(&tokens[idx + 2])?; let min_sec = self.parse_min_sec(value); @@ -1110,7 +1113,7 @@ impl Parser { if idx + 4 < len_l && tokens[idx + 3] == ":" { // TODO: (x, y) = (a, b) syntax? - let ms = self.parsems(&tokens[idx + 4]).unwrap(); + let ms = self.parsems(&tokens[idx + 4])?; res.second = Some(ms.0); res.nanosecond = Some(ms.1); @@ -1122,7 +1125,7 @@ impl Parser { { // TODO: There's got to be a better way of handling the condition above let sep = &tokens[idx + 1]; - ymd.append(value_repr.parse::()?, &value_repr, None)?; + ymd.append(value_repr.parse::()?, value_repr, None)?; if idx + 2 < len_l && !info.jump_index(&tokens[idx + 2]) { if let Ok(val) = tokens[idx + 2].parse::() { @@ -1151,14 +1154,17 @@ impl Parser { idx += 1 } else if idx + 1 >= len_l || info.jump_index(&tokens[idx + 1]) { if idx + 2 < len_l && info.ampm_index(&tokens[idx + 2]).is_some() { - let hour = value.to_i64().unwrap() as i32; - let ampm = info.ampm_index(&tokens[idx + 2]).unwrap(); + let hour = option_to_result(value.to_i64())? as i32; + let ampm = option_to_result(info.ampm_index(&tokens[idx + 2]))?; res.hour = Some(self.adjust_ampm(hour, ampm)); 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()))?; - ymd.append(value, &value_repr, None)?; + let value = value + .floor() + .to_i32() + .ok_or_else(|| ParseError::InvalidNumeric(value_repr.to_owned()))?; + ymd.append(value, value_repr, None)?; } idx += 1; @@ -1166,11 +1172,12 @@ impl Parser { && (*ZERO <= value && value < *TWENTY_FOUR) { // 12am - let hour = value.to_i64().unwrap() as i32; - res.hour = Some(self.adjust_ampm(hour, info.ampm_index(&tokens[idx + 1]).unwrap())); + let hour = option_to_result(value.to_i64())? as i32; + res.hour = + Some(self.adjust_ampm(hour, option_to_result(info.ampm_index(&tokens[idx + 1]))?)); idx += 1; - } else if ymd.could_be_day(value.to_i64().unwrap() as i32) { - ymd.append(value.to_i64().unwrap() as i32, &value_repr, None)?; + } else if ymd.could_be_day(option_to_result(value.to_i32())? as i32) { + ymd.append(option_to_result(value.to_i64())? as i32, value_repr, None)?; } else if !fuzzy { return Err(ParseError::UnrecognizedFormat); } @@ -1256,18 +1263,18 @@ impl Parser { info: &ParserInfo, hms_index: Option, ) -> (usize, Option) { - if hms_index.is_none() { - (idx, None) - } else if hms_index.unwrap() > idx { - ( - hms_index.unwrap(), - info.hms_index(&tokens[hms_index.unwrap()]), - ) - } else { - ( - idx, - info.hms_index(&tokens[hms_index.unwrap()]).map(|u| u + 1), - ) + match hms_index { + Some(index) => { + if index > idx { + (index, info.hms_index(&tokens[hms_index.unwrap()])) + } else { + ( + idx, + info.hms_index(&tokens[hms_index.unwrap()]).map(|u| u + 1), + ) + } + } + None => (idx, None), } } @@ -1277,14 +1284,14 @@ impl Parser { if hms == 0 { res.hour = value.to_i32(); if !close_to_integer(&value) { - res.minute = Some((*SIXTY * (value % *ONE)).to_i64().unwrap() as i32); + res.minute = Some(option_to_result((*SIXTY * (value % *ONE)).to_i64())? as i32); } } else if hms == 1 { let (min, sec) = self.parse_min_sec(value); res.minute = Some(min); res.second = sec; } else if hms == 2 { - let (sec, micro) = self.parsems(value_repr).unwrap(); + let (sec, micro) = self.parsems(value_repr)?; res.second = Some(sec); res.nanosecond = Some(micro); } @@ -1293,7 +1300,7 @@ impl Parser { } fn to_decimal(&self, value: &str) -> ParseResult { - Decimal::from_str(value).or_else(|_| Err(ParseError::InvalidNumeric(value.to_owned()))) + Decimal::from_str(value).map_err(|_| ParseError::InvalidNumeric(value.to_owned())) } fn parse_min_sec(&self, value: Decimal) -> (i32, Option) { diff --git a/src/tests/fuzzing.rs b/src/tests/fuzzing.rs index 2e7400b..4af504e 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] @@ -103,4 +114,4 @@ fn github_45() { assert!(parse("/2018-fifa-").is_err()); assert!(parse("/2009/07/").is_err()); assert!(parse("2021-09-").is_err()); -} \ No newline at end of file +} 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..d98045b 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_nanos(), + "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_nanos(), + "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(), + ); } diff --git a/src/weekday.rs b/src/weekday.rs index 9cd81f9..7d6a9d1 100644 --- a/src/weekday.rs +++ b/src/weekday.rs @@ -55,7 +55,7 @@ impl DayOfWeek { pub fn day_of_week(year: u32, month: u32, day: u32) -> ParseResult { // From https://en.wikipedia.org/wiki/Determination_of_the_day_of_the_week#Schwerdtfeger's_method let (c, g) = match month { - 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 => { + 3..=12 => { let c = year / 100; (c, year - 100 * c) }