Skip to content

Commit

Permalink
Leap seconds are handled even better (#508) (#525)
Browse files Browse the repository at this point in the history
Co-authored-by: Matti Hansson <matti.hansson@lm.se>
  • Loading branch information
aznan2 and Matti Hansson committed Feb 28, 2022
1 parent 9af96e8 commit 1c68e2c
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
<version.mockito>2.7.21</version.mockito>
<version.hamcrest>2.2</version.hamcrest>
<version.undertow>2.2.14.Final</version.undertow>
<version.itu>1.3.0</version.itu>
<version.itu>1.5.1</version.itu>
</properties>
<dependencies>
<dependency>
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/com/networknt/schema/DateTimeValidator.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,11 @@ private boolean isLegalDateTime(String string) {
return tryParse(() -> {
try {
ITU.parseDateTime(string);
} catch (LeapSecondException ignored) {}
} catch (LeapSecondException ex) {
if(!ex.isVerifiedValidLeapYearMonth()) {
throw ex;
}
}
});
} else {
throw new IllegalStateException("Unknown format: " + formatName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
},
{
"description": "an invalid date-time string with leap second",
"data": "1998-10-31T23:59:60Z",
"data": "1997-12-31T23:59:60Z",
"valid": false
}
]
Expand Down
2 changes: 1 addition & 1 deletion src/test/resources/draft7/optional/format/date-time.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
},
{
"description": "an invalid date-time string with leap second",
"data": "1998-10-31T23:59:60Z",
"data": "1997-12-31T23:59:60Z",
"valid": false
}
]
Expand Down

0 comments on commit 1c68e2c

Please sign in to comment.