diff --git a/README.markdown b/README.markdown index eec3394..e9043f4 100644 --- a/README.markdown +++ b/README.markdown @@ -65,6 +65,7 @@ expressed as JSON Schema definitions. | ISO | [ISO 4217:2015](https://www.iso.org/iso-4217-currency-codes.html) | Codes for the representation of currencies and funds | | ISO | [ISO 639:2023](https://www.iso.org/iso-639-language-code) | Codes for the representation of names of languages | | ISO | [ISO 8601-1:2019](https://www.iso.org/standard/70907.html) | Date and time — Representations for information interchange — Part 1: Basic rules | +| ISO | [ISO 8601-2:2019](https://www.iso.org/standard/70908.html) | Date and time — Representations for information interchange — Part 2: Extensions | | ISO | [ISO 80000-1:2022](https://www.iso.org/standard/76921.html) | Quantities and units — Part 1: General | | ISO/IEC | [ISO/IEC 2382:2015](https://www.iso.org/standard/63598.html) | Information technology — Vocabulary | | ISO/IEC | [ISO/IEC 9899:2024](https://www.iso.org/standard/82075.html) | Programming languages — C | diff --git a/schemas/iso/datetime/2019/duration/designator-extension.json b/schemas/iso/datetime/2019/duration/designator-extension.json new file mode 100644 index 0000000..103a440 --- /dev/null +++ b/schemas/iso/datetime/2019/duration/designator-extension.json @@ -0,0 +1,426 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "title": "ISO 8601-2:2019 Duration with Negative Support (Designator Format)", + "description": "A duration in designator format with optional minus sign for reverse direction P[n]Y[n]M[n]DT[n]H[n]M[n]S or -P[n]Y[n]M[n]DT[n]H[n]M[n]S (§4.4.1.9)", + "examples": [ + "P3Y6M4DT12H30M5S", + "P1Y", + "PT1H", + "P1DT1S", + "-P100D", + "-P1Y2M3D", + "-P3Y6M4DT12H30M5S", + "-PT5H30M" + ], + "x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE", + "x-links": [ "https://www.iso.org/standard/70908.html" ], + "type": "string", + "allOf": [ + { + "not": { + "const": "P" + } + }, + { + "not": { + "const": "PT" + } + }, + { + "not": { + "const": "-P" + } + }, + { + "not": { + "const": "-PT" + } + } + ], + "anyOf": [ + { + "$comment": "Positive: Date-only: Years with decimal (lowest order)", + "pattern": "^P[0-9]+(?:\\.[0-9]+)?Y$" + }, + { + "$comment": "Positive: Date-only: Years (integer) + Months with decimal (lowest order)", + "pattern": "^P[0-9]+Y[0-9]+(?:\\.[0-9]+)?M$" + }, + { + "$comment": "Positive: Date-only: Years (integer) + Months (integer) + Days with decimal (lowest order)", + "pattern": "^P[0-9]+Y[0-9]+M[0-9]+(?:\\.[0-9]+)?D$" + }, + { + "$comment": "Positive: Date-only: Months with decimal (lowest order)", + "pattern": "^P[0-9]+(?:\\.[0-9]+)?M$" + }, + { + "$comment": "Positive: Date-only: Months (integer) + Days with decimal (lowest order)", + "pattern": "^P[0-9]+M[0-9]+(?:\\.[0-9]+)?D$" + }, + { + "$comment": "Positive: Date-only: Days with decimal (lowest order)", + "pattern": "^P[0-9]+(?:\\.[0-9]+)?D$" + }, + { + "$comment": "Positive: Time-only: Hours with decimal (lowest order)", + "pattern": "^PT[0-9]+(?:\\.[0-9]+)?H$" + }, + { + "$comment": "Positive: Time-only: Hours (integer) + Minutes with decimal (lowest order)", + "pattern": "^PT[0-9]+H[0-9]+(?:\\.[0-9]+)?M$" + }, + { + "$comment": "Positive: Time-only: Hours (integer) + Minutes (integer) + Seconds with decimal (lowest order)", + "pattern": "^PT[0-9]+H[0-9]+M[0-9]+(?:\\.[0-9]+)?S$" + }, + { + "$comment": "Positive: Time-only: Minutes with decimal (lowest order)", + "pattern": "^PT[0-9]+(?:\\.[0-9]+)?M$" + }, + { + "$comment": "Positive: Time-only: Minutes (integer) + Seconds with decimal (lowest order)", + "pattern": "^PT[0-9]+M[0-9]+(?:\\.[0-9]+)?S$" + }, + { + "$comment": "Positive: Time-only: Seconds with decimal (lowest order)", + "pattern": "^PT[0-9]+(?:\\.[0-9]+)?S$" + }, + { + "$comment": "Positive: Date+Time: Years + Hours with decimal (lowest order)", + "pattern": "^P[0-9]+YT[0-9]+(?:\\.[0-9]+)?H$" + }, + { + "$comment": "Positive: Date+Time: Years + Hours (integer) + Minutes with decimal (lowest order)", + "pattern": "^P[0-9]+YT[0-9]+H[0-9]+(?:\\.[0-9]+)?M$" + }, + { + "$comment": "Positive: Date+Time: Years + Hours (integer) + Minutes (integer) + Seconds with decimal (lowest order)", + "pattern": "^P[0-9]+YT[0-9]+H[0-9]+M[0-9]+(?:\\.[0-9]+)?S$" + }, + { + "$comment": "Positive: Date+Time: Years + Minutes with decimal (lowest order)", + "pattern": "^P[0-9]+YT[0-9]+(?:\\.[0-9]+)?M$" + }, + { + "$comment": "Positive: Date+Time: Years + Minutes (integer) + Seconds with decimal (lowest order)", + "pattern": "^P[0-9]+YT[0-9]+M[0-9]+(?:\\.[0-9]+)?S$" + }, + { + "$comment": "Positive: Date+Time: Years + Seconds with decimal (lowest order)", + "pattern": "^P[0-9]+YT[0-9]+(?:\\.[0-9]+)?S$" + }, + { + "$comment": "Positive: Date+Time: Years (integer) + Months + Hours with decimal (lowest order)", + "pattern": "^P[0-9]+Y[0-9]+MT[0-9]+(?:\\.[0-9]+)?H$" + }, + { + "$comment": "Positive: Date+Time: Years (integer) + Months + Hours (integer) + Minutes with decimal (lowest order)", + "pattern": "^P[0-9]+Y[0-9]+MT[0-9]+H[0-9]+(?:\\.[0-9]+)?M$" + }, + { + "$comment": "Positive: Date+Time: Years (integer) + Months + Hours (integer) + Minutes (integer) + Seconds with decimal (lowest order)", + "pattern": "^P[0-9]+Y[0-9]+MT[0-9]+H[0-9]+M[0-9]+(?:\\.[0-9]+)?S$" + }, + { + "$comment": "Positive: Date+Time: Years (integer) + Months + Minutes with decimal (lowest order)", + "pattern": "^P[0-9]+Y[0-9]+MT[0-9]+(?:\\.[0-9]+)?M$" + }, + { + "$comment": "Positive: Date+Time: Years (integer) + Months + Minutes (integer) + Seconds with decimal (lowest order)", + "pattern": "^P[0-9]+Y[0-9]+MT[0-9]+M[0-9]+(?:\\.[0-9]+)?S$" + }, + { + "$comment": "Positive: Date+Time: Years (integer) + Months + Seconds with decimal (lowest order)", + "pattern": "^P[0-9]+Y[0-9]+MT[0-9]+(?:\\.[0-9]+)?S$" + }, + { + "$comment": "Positive: Date+Time: Years (integer) + Months (integer) + Days + Hours with decimal (lowest order)", + "pattern": "^P[0-9]+Y[0-9]+M[0-9]+DT[0-9]+(?:\\.[0-9]+)?H$" + }, + { + "$comment": "Positive: Date+Time: Years (integer) + Months (integer) + Days + Hours (integer) + Minutes with decimal (lowest order)", + "pattern": "^P[0-9]+Y[0-9]+M[0-9]+DT[0-9]+H[0-9]+(?:\\.[0-9]+)?M$" + }, + { + "$comment": "Positive: Date+Time: Years (integer) + Months (integer) + Days + Hours (integer) + Minutes (integer) + Seconds with decimal (lowest order)", + "pattern": "^P[0-9]+Y[0-9]+M[0-9]+DT[0-9]+H[0-9]+M[0-9]+(?:\\.[0-9]+)?S$" + }, + { + "$comment": "Positive: Date+Time: Years (integer) + Months (integer) + Days + Minutes with decimal (lowest order)", + "pattern": "^P[0-9]+Y[0-9]+M[0-9]+DT[0-9]+(?:\\.[0-9]+)?M$" + }, + { + "$comment": "Positive: Date+Time: Years (integer) + Months (integer) + Days + Minutes (integer) + Seconds with decimal (lowest order)", + "pattern": "^P[0-9]+Y[0-9]+M[0-9]+DT[0-9]+M[0-9]+(?:\\.[0-9]+)?S$" + }, + { + "$comment": "Positive: Date+Time: Years (integer) + Months (integer) + Days + Seconds with decimal (lowest order)", + "pattern": "^P[0-9]+Y[0-9]+M[0-9]+DT[0-9]+(?:\\.[0-9]+)?S$" + }, + { + "$comment": "Positive: Date+Time: Months + Hours with decimal (lowest order)", + "pattern": "^P[0-9]+MT[0-9]+(?:\\.[0-9]+)?H$" + }, + { + "$comment": "Positive: Date+Time: Months + Hours (integer) + Minutes with decimal (lowest order)", + "pattern": "^P[0-9]+MT[0-9]+H[0-9]+(?:\\.[0-9]+)?M$" + }, + { + "$comment": "Positive: Date+Time: Months + Hours (integer) + Minutes (integer) + Seconds with decimal (lowest order)", + "pattern": "^P[0-9]+MT[0-9]+H[0-9]+M[0-9]+(?:\\.[0-9]+)?S$" + }, + { + "$comment": "Positive: Date+Time: Months + Minutes with decimal (lowest order)", + "pattern": "^P[0-9]+MT[0-9]+(?:\\.[0-9]+)?M$" + }, + { + "$comment": "Positive: Date+Time: Months + Minutes (integer) + Seconds with decimal (lowest order)", + "pattern": "^P[0-9]+MT[0-9]+M[0-9]+(?:\\.[0-9]+)?S$" + }, + { + "$comment": "Positive: Date+Time: Months + Seconds with decimal (lowest order)", + "pattern": "^P[0-9]+MT[0-9]+(?:\\.[0-9]+)?S$" + }, + { + "$comment": "Positive: Date+Time: Months (integer) + Days + Hours with decimal (lowest order)", + "pattern": "^P[0-9]+M[0-9]+DT[0-9]+(?:\\.[0-9]+)?H$" + }, + { + "$comment": "Positive: Date+Time: Months (integer) + Days + Hours (integer) + Minutes with decimal (lowest order)", + "pattern": "^P[0-9]+M[0-9]+DT[0-9]+H[0-9]+(?:\\.[0-9]+)?M$" + }, + { + "$comment": "Positive: Date+Time: Months (integer) + Days + Hours (integer) + Minutes (integer) + Seconds with decimal (lowest order)", + "pattern": "^P[0-9]+M[0-9]+DT[0-9]+H[0-9]+M[0-9]+(?:\\.[0-9]+)?S$" + }, + { + "$comment": "Positive: Date+Time: Months (integer) + Days + Minutes with decimal (lowest order)", + "pattern": "^P[0-9]+M[0-9]+DT[0-9]+(?:\\.[0-9]+)?M$" + }, + { + "$comment": "Positive: Date+Time: Months (integer) + Days + Minutes (integer) + Seconds with decimal (lowest order)", + "pattern": "^P[0-9]+M[0-9]+DT[0-9]+M[0-9]+(?:\\.[0-9]+)?S$" + }, + { + "$comment": "Positive: Date+Time: Months (integer) + Days + Seconds with decimal (lowest order)", + "pattern": "^P[0-9]+M[0-9]+DT[0-9]+(?:\\.[0-9]+)?S$" + }, + { + "$comment": "Positive: Date+Time: Days + Hours with decimal (lowest order)", + "pattern": "^P[0-9]+DT[0-9]+(?:\\.[0-9]+)?H$" + }, + { + "$comment": "Positive: Date+Time: Days + Hours (integer) + Minutes with decimal (lowest order)", + "pattern": "^P[0-9]+DT[0-9]+H[0-9]+(?:\\.[0-9]+)?M$" + }, + { + "$comment": "Positive: Date+Time: Days + Hours (integer) + Minutes (integer) + Seconds with decimal (lowest order)", + "pattern": "^P[0-9]+DT[0-9]+H[0-9]+M[0-9]+(?:\\.[0-9]+)?S$" + }, + { + "$comment": "Positive: Date+Time: Days + Minutes with decimal (lowest order)", + "pattern": "^P[0-9]+DT[0-9]+(?:\\.[0-9]+)?M$" + }, + { + "$comment": "Positive: Date+Time: Days + Minutes (integer) + Seconds with decimal (lowest order)", + "pattern": "^P[0-9]+DT[0-9]+M[0-9]+(?:\\.[0-9]+)?S$" + }, + { + "$comment": "Positive: Date+Time: Days + Seconds with decimal (lowest order)", + "pattern": "^P[0-9]+DT[0-9]+(?:\\.[0-9]+)?S$" + }, + { + "$comment": "Negative: Date-only: Years with decimal (lowest order)", + "pattern": "^-P[0-9]+(?:\\.[0-9]+)?Y$" + }, + { + "$comment": "Negative: Date-only: Years (integer) + Months with decimal (lowest order)", + "pattern": "^-P[0-9]+Y[0-9]+(?:\\.[0-9]+)?M$" + }, + { + "$comment": "Negative: Date-only: Years (integer) + Months (integer) + Days with decimal (lowest order)", + "pattern": "^-P[0-9]+Y[0-9]+M[0-9]+(?:\\.[0-9]+)?D$" + }, + { + "$comment": "Negative: Date-only: Months with decimal (lowest order)", + "pattern": "^-P[0-9]+(?:\\.[0-9]+)?M$" + }, + { + "$comment": "Negative: Date-only: Months (integer) + Days with decimal (lowest order)", + "pattern": "^-P[0-9]+M[0-9]+(?:\\.[0-9]+)?D$" + }, + { + "$comment": "Negative: Date-only: Days with decimal (lowest order)", + "pattern": "^-P[0-9]+(?:\\.[0-9]+)?D$" + }, + { + "$comment": "Negative: Time-only: Hours with decimal (lowest order)", + "pattern": "^-PT[0-9]+(?:\\.[0-9]+)?H$" + }, + { + "$comment": "Negative: Time-only: Hours (integer) + Minutes with decimal (lowest order)", + "pattern": "^-PT[0-9]+H[0-9]+(?:\\.[0-9]+)?M$" + }, + { + "$comment": "Negative: Time-only: Hours (integer) + Minutes (integer) + Seconds with decimal (lowest order)", + "pattern": "^-PT[0-9]+H[0-9]+M[0-9]+(?:\\.[0-9]+)?S$" + }, + { + "$comment": "Negative: Time-only: Minutes with decimal (lowest order)", + "pattern": "^-PT[0-9]+(?:\\.[0-9]+)?M$" + }, + { + "$comment": "Negative: Time-only: Minutes (integer) + Seconds with decimal (lowest order)", + "pattern": "^-PT[0-9]+M[0-9]+(?:\\.[0-9]+)?S$" + }, + { + "$comment": "Negative: Time-only: Seconds with decimal (lowest order)", + "pattern": "^-PT[0-9]+(?:\\.[0-9]+)?S$" + }, + { + "$comment": "Negative: Date+Time: Years + Hours with decimal (lowest order)", + "pattern": "^-P[0-9]+YT[0-9]+(?:\\.[0-9]+)?H$" + }, + { + "$comment": "Negative: Date+Time: Years + Hours (integer) + Minutes with decimal (lowest order)", + "pattern": "^-P[0-9]+YT[0-9]+H[0-9]+(?:\\.[0-9]+)?M$" + }, + { + "$comment": "Negative: Date+Time: Years + Hours (integer) + Minutes (integer) + Seconds with decimal (lowest order)", + "pattern": "^-P[0-9]+YT[0-9]+H[0-9]+M[0-9]+(?:\\.[0-9]+)?S$" + }, + { + "$comment": "Negative: Date+Time: Years + Minutes with decimal (lowest order)", + "pattern": "^-P[0-9]+YT[0-9]+(?:\\.[0-9]+)?M$" + }, + { + "$comment": "Negative: Date+Time: Years + Minutes (integer) + Seconds with decimal (lowest order)", + "pattern": "^-P[0-9]+YT[0-9]+M[0-9]+(?:\\.[0-9]+)?S$" + }, + { + "$comment": "Negative: Date+Time: Years + Seconds with decimal (lowest order)", + "pattern": "^-P[0-9]+YT[0-9]+(?:\\.[0-9]+)?S$" + }, + { + "$comment": "Negative: Date+Time: Years (integer) + Months + Hours with decimal (lowest order)", + "pattern": "^-P[0-9]+Y[0-9]+MT[0-9]+(?:\\.[0-9]+)?H$" + }, + { + "$comment": "Negative: Date+Time: Years (integer) + Months + Hours (integer) + Minutes with decimal (lowest order)", + "pattern": "^-P[0-9]+Y[0-9]+MT[0-9]+H[0-9]+(?:\\.[0-9]+)?M$" + }, + { + "$comment": "Negative: Date+Time: Years (integer) + Months + Hours (integer) + Minutes (integer) + Seconds with decimal (lowest order)", + "pattern": "^-P[0-9]+Y[0-9]+MT[0-9]+H[0-9]+M[0-9]+(?:\\.[0-9]+)?S$" + }, + { + "$comment": "Negative: Date+Time: Years (integer) + Months + Minutes with decimal (lowest order)", + "pattern": "^-P[0-9]+Y[0-9]+MT[0-9]+(?:\\.[0-9]+)?M$" + }, + { + "$comment": "Negative: Date+Time: Years (integer) + Months + Minutes (integer) + Seconds with decimal (lowest order)", + "pattern": "^-P[0-9]+Y[0-9]+MT[0-9]+M[0-9]+(?:\\.[0-9]+)?S$" + }, + { + "$comment": "Negative: Date+Time: Years (integer) + Months + Seconds with decimal (lowest order)", + "pattern": "^-P[0-9]+Y[0-9]+MT[0-9]+(?:\\.[0-9]+)?S$" + }, + { + "$comment": "Negative: Date+Time: Years (integer) + Months (integer) + Days + Hours with decimal (lowest order)", + "pattern": "^-P[0-9]+Y[0-9]+M[0-9]+DT[0-9]+(?:\\.[0-9]+)?H$" + }, + { + "$comment": "Negative: Date+Time: Years (integer) + Months (integer) + Days + Hours (integer) + Minutes with decimal (lowest order)", + "pattern": "^-P[0-9]+Y[0-9]+M[0-9]+DT[0-9]+H[0-9]+(?:\\.[0-9]+)?M$" + }, + { + "$comment": "Negative: Date+Time: Years (integer) + Months (integer) + Days + Hours (integer) + Minutes (integer) + Seconds with decimal (lowest order)", + "pattern": "^-P[0-9]+Y[0-9]+M[0-9]+DT[0-9]+H[0-9]+M[0-9]+(?:\\.[0-9]+)?S$" + }, + { + "$comment": "Negative: Date+Time: Years (integer) + Months (integer) + Days + Minutes with decimal (lowest order)", + "pattern": "^-P[0-9]+Y[0-9]+M[0-9]+DT[0-9]+(?:\\.[0-9]+)?M$" + }, + { + "$comment": "Negative: Date+Time: Years (integer) + Months (integer) + Days + Minutes (integer) + Seconds with decimal (lowest order)", + "pattern": "^-P[0-9]+Y[0-9]+M[0-9]+DT[0-9]+M[0-9]+(?:\\.[0-9]+)?S$" + }, + { + "$comment": "Negative: Date+Time: Years (integer) + Months (integer) + Days + Seconds with decimal (lowest order)", + "pattern": "^-P[0-9]+Y[0-9]+M[0-9]+DT[0-9]+(?:\\.[0-9]+)?S$" + }, + { + "$comment": "Negative: Date+Time: Months + Hours with decimal (lowest order)", + "pattern": "^-P[0-9]+MT[0-9]+(?:\\.[0-9]+)?H$" + }, + { + "$comment": "Negative: Date+Time: Months + Hours (integer) + Minutes with decimal (lowest order)", + "pattern": "^-P[0-9]+MT[0-9]+H[0-9]+(?:\\.[0-9]+)?M$" + }, + { + "$comment": "Negative: Date+Time: Months + Hours (integer) + Minutes (integer) + Seconds with decimal (lowest order)", + "pattern": "^-P[0-9]+MT[0-9]+H[0-9]+M[0-9]+(?:\\.[0-9]+)?S$" + }, + { + "$comment": "Negative: Date+Time: Months + Minutes with decimal (lowest order)", + "pattern": "^-P[0-9]+MT[0-9]+(?:\\.[0-9]+)?M$" + }, + { + "$comment": "Negative: Date+Time: Months + Minutes (integer) + Seconds with decimal (lowest order)", + "pattern": "^-P[0-9]+MT[0-9]+M[0-9]+(?:\\.[0-9]+)?S$" + }, + { + "$comment": "Negative: Date+Time: Months + Seconds with decimal (lowest order)", + "pattern": "^-P[0-9]+MT[0-9]+(?:\\.[0-9]+)?S$" + }, + { + "$comment": "Negative: Date+Time: Months (integer) + Days + Hours with decimal (lowest order)", + "pattern": "^-P[0-9]+M[0-9]+DT[0-9]+(?:\\.[0-9]+)?H$" + }, + { + "$comment": "Negative: Date+Time: Months (integer) + Days + Hours (integer) + Minutes with decimal (lowest order)", + "pattern": "^-P[0-9]+M[0-9]+DT[0-9]+H[0-9]+(?:\\.[0-9]+)?M$" + }, + { + "$comment": "Negative: Date+Time: Months (integer) + Days + Hours (integer) + Minutes (integer) + Seconds with decimal (lowest order)", + "pattern": "^-P[0-9]+M[0-9]+DT[0-9]+H[0-9]+M[0-9]+(?:\\.[0-9]+)?S$" + }, + { + "$comment": "Negative: Date+Time: Months (integer) + Days + Minutes with decimal (lowest order)", + "pattern": "^-P[0-9]+M[0-9]+DT[0-9]+(?:\\.[0-9]+)?M$" + }, + { + "$comment": "Negative: Date+Time: Months (integer) + Days + Minutes (integer) + Seconds with decimal (lowest order)", + "pattern": "^-P[0-9]+M[0-9]+DT[0-9]+M[0-9]+(?:\\.[0-9]+)?S$" + }, + { + "$comment": "Negative: Date+Time: Months (integer) + Days + Seconds with decimal (lowest order)", + "pattern": "^-P[0-9]+M[0-9]+DT[0-9]+(?:\\.[0-9]+)?S$" + }, + { + "$comment": "Negative: Date+Time: Days + Hours with decimal (lowest order)", + "pattern": "^-P[0-9]+DT[0-9]+(?:\\.[0-9]+)?H$" + }, + { + "$comment": "Negative: Date+Time: Days + Hours (integer) + Minutes with decimal (lowest order)", + "pattern": "^-P[0-9]+DT[0-9]+H[0-9]+(?:\\.[0-9]+)?M$" + }, + { + "$comment": "Negative: Date+Time: Days + Hours (integer) + Minutes (integer) + Seconds with decimal (lowest order)", + "pattern": "^-P[0-9]+DT[0-9]+H[0-9]+M[0-9]+(?:\\.[0-9]+)?S$" + }, + { + "$comment": "Negative: Date+Time: Days + Minutes with decimal (lowest order)", + "pattern": "^-P[0-9]+DT[0-9]+(?:\\.[0-9]+)?M$" + }, + { + "$comment": "Negative: Date+Time: Days + Minutes (integer) + Seconds with decimal (lowest order)", + "pattern": "^-P[0-9]+DT[0-9]+M[0-9]+(?:\\.[0-9]+)?S$" + }, + { + "$comment": "Negative: Date+Time: Days + Seconds with decimal (lowest order)", + "pattern": "^-P[0-9]+DT[0-9]+(?:\\.[0-9]+)?S$" + } + ] +} diff --git a/test/iso/datetime/2019/duration/designator-extension.test.json b/test/iso/datetime/2019/duration/designator-extension.test.json new file mode 100644 index 0000000..55badf9 --- /dev/null +++ b/test/iso/datetime/2019/duration/designator-extension.test.json @@ -0,0 +1,341 @@ +{ + "x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE", + "target": "../../../../../schemas/iso/datetime/2019/duration/designator-extension.json", + "tests": [ + { + "description": "Invalid type - integer", + "data": 123, + "valid": false + }, + { + "description": "Invalid type - boolean", + "data": true, + "valid": false + }, + { + "description": "Invalid type - null", + "data": null, + "valid": false + }, + { + "description": "Invalid type - array", + "data": [], + "valid": false + }, + { + "description": "Invalid type - object", + "data": {}, + "valid": false + }, + { + "description": "Valid - full duration with all components", + "data": "P3Y6M4DT12H30M5S", + "valid": true + }, + { + "description": "Valid - only years", + "data": "P1Y", + "valid": true + }, + { + "description": "Valid - only time component (hours)", + "data": "PT1H", + "valid": true + }, + { + "description": "Valid - days and seconds", + "data": "P1DT1S", + "valid": true + }, + { + "description": "Valid - all zeros", + "data": "P0Y0M0DT0H0M0S", + "valid": true + }, + { + "description": "Valid - only months", + "data": "P5M", + "valid": true + }, + { + "description": "Valid - only days", + "data": "P100D", + "valid": true + }, + { + "description": "Valid - only minutes", + "data": "PT30M", + "valid": true + }, + { + "description": "Valid - only seconds", + "data": "PT45S", + "valid": true + }, + { + "description": "Valid - seconds with decimal fraction", + "data": "PT1.5S", + "valid": true + }, + { + "description": "Valid - years and months", + "data": "P2Y3M", + "valid": true + }, + { + "description": "Valid - hours and minutes", + "data": "PT12H30M", + "valid": true + }, + { + "description": "Invalid - missing P prefix", + "data": "3Y6M4DT12H30M5S", + "valid": false + }, + { + "description": "Invalid - lowercase p", + "data": "p1Y", + "valid": false + }, + { + "description": "Invalid - lowercase t", + "data": "P1Dt1H", + "valid": false + }, + { + "description": "Invalid - time component without T", + "data": "P1D1H", + "valid": false + }, + { + "description": "Invalid - empty string", + "data": "", + "valid": false + }, + { + "description": "Invalid - only P", + "data": "P", + "valid": false + }, + { + "description": "Invalid - only PT", + "data": "PT", + "valid": false + }, + { + "description": "Invalid - spaces in duration", + "data": "P1Y 2M", + "valid": false + }, + { + "description": "Invalid - wrong order (months before years)", + "data": "P6M3Y", + "valid": false + }, + { + "description": "Valid - 13 months (durations can exceed calendar limits)", + "data": "P13M", + "valid": true + }, + { + "description": "Valid - 32 days (durations can exceed calendar limits)", + "data": "P32D", + "valid": true + }, + { + "description": "Valid - 25 hours (durations can exceed calendar limits)", + "data": "PT25H", + "valid": true + }, + { + "description": "Valid - 60 minutes (durations can exceed calendar limits)", + "data": "PT60M", + "valid": true + }, + { + "description": "Valid - 60 seconds (durations can exceed calendar limits)", + "data": "PT60S", + "valid": true + }, + { + "description": "Valid - 100 hours (durations can exceed calendar limits)", + "data": "PT100H", + "valid": true + }, + { + "description": "Valid - 500 days (durations can exceed calendar limits)", + "data": "P500D", + "valid": true + }, + { + "description": "Valid - zero years", + "data": "P0Y", + "valid": true + }, + { + "description": "Valid - zero months", + "data": "P0M", + "valid": true + }, + { + "description": "Valid - zero days", + "data": "P0D", + "valid": true + }, + { + "description": "Valid - zero hours", + "data": "PT0H", + "valid": true + }, + { + "description": "Valid - zero minutes", + "data": "PT0M", + "valid": true + }, + { + "description": "Valid - zero seconds", + "data": "PT0S", + "valid": true + }, + { + "description": "Valid negative - days only", + "data": "-P100D", + "valid": true + }, + { + "description": "Valid negative - year month and days", + "data": "-P1Y2M3D", + "valid": true + }, + { + "description": "Valid negative - full representation", + "data": "-P3Y6M4DT12H30M5S", + "valid": true + }, + { + "description": "Valid negative - time only hours and minutes", + "data": "-PT5H30M", + "valid": true + }, + { + "description": "Valid negative - year only", + "data": "-P1Y", + "valid": true + }, + { + "description": "Valid negative - hours only", + "data": "-PT1H", + "valid": true + }, + { + "description": "Valid negative - decimal year", + "data": "-P1.5Y", + "valid": true + }, + { + "description": "Valid negative - months only", + "data": "-P6M", + "valid": true + }, + { + "description": "Valid negative - seconds only", + "data": "-PT30S", + "valid": true + }, + { + "description": "Valid negative - year month day", + "data": "-P1Y2M3D", + "valid": true + }, + { + "description": "Valid negative - hours minutes seconds", + "data": "-PT10H20M30S", + "valid": true + }, + { + "description": "Valid negative - decimal seconds", + "data": "-PT1.5S", + "valid": true + }, + { + "description": "Valid negative - zero duration", + "data": "-P0Y0M0DT0H0M0S", + "valid": true + }, + { + "description": "Invalid - empty P", + "data": "P", + "valid": false + }, + { + "description": "Invalid - empty PT", + "data": "PT", + "valid": false + }, + { + "description": "Invalid - empty -P", + "data": "-P", + "valid": false + }, + { + "description": "Invalid - empty -PT", + "data": "-PT", + "valid": false + }, + { + "description": "Invalid - double minus", + "data": "--P1Y", + "valid": false + }, + { + "description": "Invalid - minus in wrong position", + "data": "P-1Y", + "valid": false + }, + { + "description": "Invalid - missing P", + "data": "-1Y", + "valid": false + }, + { + "description": "Invalid - missing T separator", + "data": "-P1Y1H", + "valid": false + }, + { + "description": "Invalid - wrong designator order", + "data": "-P1D2M3Y", + "valid": false + }, + { + "description": "Invalid - time before date", + "data": "-PT1H1D", + "valid": false + }, + { + "description": "Invalid type - number", + "data": 100, + "valid": false + }, + { + "description": "Invalid type - boolean", + "data": true, + "valid": false + }, + { + "description": "Invalid type - null", + "data": null, + "valid": false + }, + { + "description": "Invalid type - array", + "data": [], + "valid": false + }, + { + "description": "Invalid type - object", + "data": {}, + "valid": false + } + ] +}