Skip to content

Commit

Permalink
Move checks for parse_from_rfc2822 to the correct test
Browse files Browse the repository at this point in the history
  • Loading branch information
pitdicker committed Jul 24, 2023
1 parent 05cab13 commit 3f2ecbe
Showing 1 changed file with 23 additions and 23 deletions.
46 changes: 23 additions & 23 deletions src/datetime/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,29 @@ fn test_datetime_rfc2822() {
.to_rfc2822(),
"Wed, 18 Feb 2015 23:16:09 +0500"
);
assert_eq!(
DateTime::parse_from_rfc2822("Wed, 18 Feb 2015 23:59:60 +0500"),
Ok(edt
.from_local_datetime(
&NaiveDate::from_ymd_opt(2015, 2, 18)
.unwrap()
.and_hms_milli_opt(23, 59, 59, 1_000)
.unwrap()
)
.unwrap())
);
assert!(DateTime::parse_from_rfc2822("31 DEC 262143 23:59 -2359").is_err());
assert_eq!(
DateTime::parse_from_rfc3339("2015-02-18T23:59:60.234567+05:00"),
Ok(edt
.from_local_datetime(
&NaiveDate::from_ymd_opt(2015, 2, 18)
.unwrap()
.and_hms_micro_opt(23, 59, 59, 1_234_567)
.unwrap()
)
.unwrap())
);
// seconds 60
assert_eq!(
edt.from_local_datetime(
Expand Down Expand Up @@ -619,29 +642,6 @@ fn test_datetime_rfc3339() {
DateTime::parse_from_rfc3339("2015-02-18 23:59:60.234567+05:00"),
Ok(ymdhms_micro(&edt5, 2015, 2, 18, 23, 59, 59, 1_234_567))
);
assert_eq!(
DateTime::parse_from_rfc2822("Wed, 18 Feb 2015 23:59:60 +0500"),
Ok(edt5
.from_local_datetime(
&NaiveDate::from_ymd_opt(2015, 2, 18)
.unwrap()
.and_hms_milli_opt(23, 59, 59, 1_000)
.unwrap()
)
.unwrap())
);
assert!(DateTime::parse_from_rfc2822("31 DEC 262143 23:59 -2359").is_err());
assert_eq!(
DateTime::parse_from_rfc3339("2015-02-18T23:59:60.234567+05:00"),
Ok(edt5
.from_local_datetime(
&NaiveDate::from_ymd_opt(2015, 2, 18)
.unwrap()
.and_hms_micro_opt(23, 59, 59, 1_234_567)
.unwrap()
)
.unwrap())
);
assert_eq!(ymdhms_utc(2015, 2, 18, 23, 16, 9).to_rfc3339(), "2015-02-18T23:16:09+00:00");

assert!(DateTime::parse_from_rfc3339("2015-02-18T23:59:60.234567 +05:00").is_err());
Expand Down

0 comments on commit 3f2ecbe

Please sign in to comment.