Skip to content

Commit 1112eff

Browse files
authored
Fix some XML Schema date/time/duration correctness issues (#102)
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
1 parent e1e5e1a commit 1112eff

6 files changed

Lines changed: 12 additions & 11 deletions

File tree

schemas/2020-12/w3c/xmlschema/2001/date-time.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@
1313
"x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE",
1414
"x-links": [ "https://www.w3.org/TR/xmlschema-2/#dateTime" ],
1515
"type": "string",
16-
"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])?$"
16+
"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))?$"
1717
}

schemas/2020-12/w3c/xmlschema/2001/duration.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@
1212
],
1313
"x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE",
1414
"x-links": [ "https://www.w3.org/TR/xmlschema-2/#duration" ],
15-
"$ref": "../../../iso/datetime/2019/duration/designator-extension.json"
15+
"type": "string",
16+
"pattern": "^-?P(?=.)([0-9]+Y)?([0-9]+M)?([0-9]+D)?(T(?=.)([0-9]+H)?([0-9]+M)?([0-9]+(\\.[0-9]+)?S)?)?$"
1617
}

schemas/2020-12/w3c/xmlschema/2001/time.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@
1313
"x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE",
1414
"x-links": [ "https://www.w3.org/TR/xmlschema-2/#time" ],
1515
"type": "string",
16-
"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])?$"
16+
"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))?$"
1717
}

test/w3c/xmlschema/2001/date-time.test.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@
4242
"valid": true
4343
},
4444
{
45-
"description": "Valid - leap second",
45+
"description": "Invalid - leap second is not an XSD dateTime",
4646
"data": "2023-12-31T23:59:60Z",
47-
"valid": true
47+
"valid": false
4848
},
4949
{
5050
"description": "Valid - negative year",
@@ -87,9 +87,9 @@
8787
"valid": false
8888
},
8989
{
90-
"description": "Invalid - hour 24",
90+
"description": "Valid - hour 24 as midnight",
9191
"data": "2023-05-15T24:00:00",
92-
"valid": false
92+
"valid": true
9393
},
9494
{
9595
"description": "Invalid - minute 60",

test/w3c/xmlschema/2001/duration.test.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@
5252
"valid": true
5353
},
5454
{
55-
"description": "Valid - negative duration with decimal",
55+
"description": "Invalid - decimal fraction only allowed on seconds",
5656
"data": "-PT30.5M",
57-
"valid": true
57+
"valid": false
5858
},
5959
{
6060
"description": "Invalid - empty P",

test/w3c/xmlschema/2001/time.test.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@
4747
"valid": true
4848
},
4949
{
50-
"description": "Valid - leap second",
50+
"description": "Invalid - leap second is not an XSD time",
5151
"data": "23:59:60",
52-
"valid": true
52+
"valid": false
5353
},
5454
{
5555
"description": "Invalid - hour 25",

0 commit comments

Comments
 (0)