From 5d21212e8b557366064845e401622ab83490d81c Mon Sep 17 00:00:00 2001 From: Matti Hansson Date: Mon, 28 Feb 2022 11:14:09 +0100 Subject: [PATCH] Leap seconds are handled even better (#508) --- pom.xml | 2 +- src/main/java/com/networknt/schema/DateTimeValidator.java | 6 +++++- .../resources/draft2019-09/optional/format/date-time.json | 2 +- src/test/resources/draft7/optional/format/date-time.json | 2 +- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index e14286055..1fe50e6d8 100644 --- a/pom.xml +++ b/pom.xml @@ -71,7 +71,7 @@ 2.7.21 2.2 2.2.14.Final - 1.3.0 + 1.5.1 diff --git a/src/main/java/com/networknt/schema/DateTimeValidator.java b/src/main/java/com/networknt/schema/DateTimeValidator.java index db3d4bae3..69a082e3c 100644 --- a/src/main/java/com/networknt/schema/DateTimeValidator.java +++ b/src/main/java/com/networknt/schema/DateTimeValidator.java @@ -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); diff --git a/src/test/resources/draft2019-09/optional/format/date-time.json b/src/test/resources/draft2019-09/optional/format/date-time.json index b183a8d02..6baa1a564 100644 --- a/src/test/resources/draft2019-09/optional/format/date-time.json +++ b/src/test/resources/draft2019-09/optional/format/date-time.json @@ -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 } ] diff --git a/src/test/resources/draft7/optional/format/date-time.json b/src/test/resources/draft7/optional/format/date-time.json index b183a8d02..6baa1a564 100644 --- a/src/test/resources/draft7/optional/format/date-time.json +++ b/src/test/resources/draft7/optional/format/date-time.json @@ -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 } ]