Skip to content

Commit

Permalink
Permit leap seconds when parsing ISO 8601
Browse files Browse the repository at this point in the history
  • Loading branch information
jhpratt committed Apr 10, 2024
1 parent d279d8d commit 9c15ee3
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tests/serde/iso8601.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,25 @@ fn deserialize_error() {
"the 'year' component could not be parsed",
);
}

#[test]
fn issue_674_leap_second_support() {
serde_test::assert_de_tokens::<Test>(
&Test {
dt: datetime!(2016-12-31 23:59:59.999999999 UTC),
option_dt: Some(datetime!(2016-12-31 23:59:59.999999999 UTC)),
},
&[
Token::Struct {
name: "Test",
len: 2,
},
Token::Str("dt"),
Token::BorrowedStr("2016-12-31T23:59:60.000Z"),
Token::Str("option_dt"),
Token::Some,
Token::BorrowedStr("2016-12-31T23:59:60.000Z"),
Token::StructEnd,
],
);
}
2 changes: 2 additions & 0 deletions time/src/parsing/parsable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -739,6 +739,8 @@ impl<const CONFIG: EncodedConfig> sealed::Sealed for Iso8601<CONFIG> {
let mut offset_is_present = false;
let mut first_error = None;

parsed.leap_second_allowed = true;

match Self::parse_date(parsed, &mut extended_kind)(input) {
Ok(new_input) => {
input = new_input;
Expand Down

0 comments on commit 9c15ee3

Please sign in to comment.