From 52e4d3e36d0f126482064cad8a3bd863da378739 Mon Sep 17 00:00:00 2001 From: Juan Cruz Viotti Date: Mon, 27 Jul 2026 12:51:42 -0300 Subject: [PATCH] Fix some XML Schema date/time/duration correctness issues Signed-off-by: Juan Cruz Viotti --- schemas/2020-12/w3c/xmlschema/2001/date-time.json | 2 +- schemas/2020-12/w3c/xmlschema/2001/duration.json | 3 ++- schemas/2020-12/w3c/xmlschema/2001/time.json | 2 +- test/w3c/xmlschema/2001/date-time.test.json | 8 ++++---- test/w3c/xmlschema/2001/duration.test.json | 4 ++-- test/w3c/xmlschema/2001/time.test.json | 4 ++-- 6 files changed, 12 insertions(+), 11 deletions(-) diff --git a/schemas/2020-12/w3c/xmlschema/2001/date-time.json b/schemas/2020-12/w3c/xmlschema/2001/date-time.json index 59161016..2a075d42 100644 --- a/schemas/2020-12/w3c/xmlschema/2001/date-time.json +++ b/schemas/2020-12/w3c/xmlschema/2001/date-time.json @@ -13,5 +13,5 @@ "x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE", "x-links": [ "https://www.w3.org/TR/xmlschema-2/#dateTime" ], "type": "string", - "pattern": "^-?((?!0000)[0-9]{4}-(0[13578]|1[02])-(0[1-9]|[12][0-9]|3[01])|(?!0000)[0-9]{4}-(0[469]|11)-(0[1-9]|[12][0-9]|30)|(?!0000)[0-9]{4}-02-(0[1-9]|1[0-9]|2[0-9]))T([01][0-9]|2[0-3]):[0-5][0-9]:([0-5][0-9]|60)(\\.[0-9]+)?(Z|[+-]([01][0-9]|2[0-3]):[0-5][0-9])?$" + "pattern": "^-?((?!0000)[0-9]{4}-(0[13578]|1[02])-(0[1-9]|[12][0-9]|3[01])|(?!0000)[0-9]{4}-(0[469]|11)-(0[1-9]|[12][0-9]|30)|(?!0000)[0-9]{4}-02-(0[1-9]|1[0-9]|2[0-9]))T(([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](\\.[0-9]+)?|24:00:00(\\.0+)?)(Z|[+-]((0[0-9]|1[0-3]):[0-5][0-9]|14:00))?$" } diff --git a/schemas/2020-12/w3c/xmlschema/2001/duration.json b/schemas/2020-12/w3c/xmlschema/2001/duration.json index 99df7b4f..ded6583d 100644 --- a/schemas/2020-12/w3c/xmlschema/2001/duration.json +++ b/schemas/2020-12/w3c/xmlschema/2001/duration.json @@ -12,5 +12,6 @@ ], "x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE", "x-links": [ "https://www.w3.org/TR/xmlschema-2/#duration" ], - "$ref": "../../../iso/datetime/2019/duration/designator-extension.json" + "type": "string", + "pattern": "^-?P(?=.)([0-9]+Y)?([0-9]+M)?([0-9]+D)?(T(?=.)([0-9]+H)?([0-9]+M)?([0-9]+(\\.[0-9]+)?S)?)?$" } diff --git a/schemas/2020-12/w3c/xmlschema/2001/time.json b/schemas/2020-12/w3c/xmlschema/2001/time.json index 36705d84..4aac7d10 100644 --- a/schemas/2020-12/w3c/xmlschema/2001/time.json +++ b/schemas/2020-12/w3c/xmlschema/2001/time.json @@ -13,5 +13,5 @@ "x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE", "x-links": [ "https://www.w3.org/TR/xmlschema-2/#time" ], "type": "string", - "pattern": "^(([01][0-9]|2[0-3]):[0-5][0-9]:([0-5][0-9]|60)(\\.[0-9]+)?|24:00:00)(Z|[+-]([01][0-9]|2[0-3]):[0-5][0-9])?$" + "pattern": "^(([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](\\.[0-9]+)?|24:00:00(\\.0+)?)(Z|[+-]((0[0-9]|1[0-3]):[0-5][0-9]|14:00))?$" } diff --git a/test/w3c/xmlschema/2001/date-time.test.json b/test/w3c/xmlschema/2001/date-time.test.json index 02779f6c..e70efed3 100644 --- a/test/w3c/xmlschema/2001/date-time.test.json +++ b/test/w3c/xmlschema/2001/date-time.test.json @@ -42,9 +42,9 @@ "valid": true }, { - "description": "Valid - leap second", + "description": "Invalid - leap second is not an XSD dateTime", "data": "2023-12-31T23:59:60Z", - "valid": true + "valid": false }, { "description": "Valid - negative year", @@ -87,9 +87,9 @@ "valid": false }, { - "description": "Invalid - hour 24", + "description": "Valid - hour 24 as midnight", "data": "2023-05-15T24:00:00", - "valid": false + "valid": true }, { "description": "Invalid - minute 60", diff --git a/test/w3c/xmlschema/2001/duration.test.json b/test/w3c/xmlschema/2001/duration.test.json index 4597dc8f..999b07ce 100644 --- a/test/w3c/xmlschema/2001/duration.test.json +++ b/test/w3c/xmlschema/2001/duration.test.json @@ -52,9 +52,9 @@ "valid": true }, { - "description": "Valid - negative duration with decimal", + "description": "Invalid - decimal fraction only allowed on seconds", "data": "-PT30.5M", - "valid": true + "valid": false }, { "description": "Invalid - empty P", diff --git a/test/w3c/xmlschema/2001/time.test.json b/test/w3c/xmlschema/2001/time.test.json index 0cfdb65c..1afa5563 100644 --- a/test/w3c/xmlschema/2001/time.test.json +++ b/test/w3c/xmlschema/2001/time.test.json @@ -47,9 +47,9 @@ "valid": true }, { - "description": "Valid - leap second", + "description": "Invalid - leap second is not an XSD time", "data": "23:59:60", - "valid": true + "valid": false }, { "description": "Invalid - hour 25",