Skip to content

Commit 5ebad30

Browse files
authored
Define ISO 8601-1:2019 durations (#13)
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
1 parent 426ce32 commit 5ebad30

13 files changed

+1703
-0
lines changed

README.markdown

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ expressed as JSON Schema definitions.
4848
| IETF | [RFC 8141](https://www.rfc-editor.org/rfc/rfc8141) | Uniform Resource Names (URNs) |
4949
| IETF | [RFC 9110](https://www.rfc-editor.org/rfc/rfc9110) | HTTP Semantics |
5050
| ISO | [ISO 4217](https://www.iso.org/iso-4217-currency-codes.html) | Codes for the representation of currencies and funds |
51+
| ISO | [ISO 8601-1:2019](https://www.iso.org/standard/70907.html) | Date and time — Representations for information interchange — Part 1: Basic rules |
5152
| ISO | [ISO 80000-1:2022](https://www.iso.org/standard/76921.html) | Quantities and units — Part 1: General |
5253
| ISO/IEC | [ISO/IEC 2382:2015](https://www.iso.org/standard/63598.html) | Information technology — Vocabulary |
5354
| JSON-RPC | [JSON-RPC 2.0](https://www.jsonrpc.org/specification) | JSON-RPC 2.0 Specification |
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
3+
"title": "ISO 8601-1:2019 Duration (Alternative Calendar Basic Format)",
4+
"description": "A duration in alternative basic format P[YYYYMMDD]T[HHMMSS] (§5.5.2.4)",
5+
"$comment": "https://www.iso.org/standard/70907.html",
6+
"examples": [ "P00020110T223355", "P00010101T000000", "P00001231T235959" ],
7+
"x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE",
8+
"type": "string",
9+
"pattern": "^P(?:[0-9]{4}|[+-][0-9]{5,})(?:0[1-9]|1[0-2])(?:0[1-9]|[12][0-9]|3[01])T(?:[01][0-9]|2[0-3])(?:[0-5][0-9])(?:[0-5][0-9])$"
10+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
3+
"title": "ISO 8601-1:2019 Duration (Alternative Calendar Extended Format)",
4+
"description": "A duration in alternative extended format P[YYYY-MM-DD]T[HH:MM:SS] (§5.5.2.4)",
5+
"$comment": "https://www.iso.org/standard/70907.html",
6+
"examples": [
7+
"P0002-01-10T22:33:55",
8+
"P0001-01-01T00:00:00",
9+
"P0001-12-31T23:59:59"
10+
],
11+
"x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE",
12+
"type": "string",
13+
"pattern": "^P(?:[0-9]{4}|[+-][0-9]{5,})-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12][0-9]|3[01])T(?:[01][0-9]|2[0-3]):(?:[0-5][0-9]):(?:[0-5][0-9])$"
14+
}
Lines changed: 223 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,223 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
3+
"title": "ISO 8601-1:2019 Duration (Designator Format)",
4+
"description": "A duration in designator format P[n]Y[n]M[n]DT[n]H[n]M[n]S (§5.5.2.2, §5.5.2.3)",
5+
"$comment": "https://www.iso.org/standard/70907.html",
6+
"examples": [
7+
"P3Y6M4DT12H30M5S",
8+
"P1Y",
9+
"PT1H",
10+
"P1DT1S",
11+
"P0Y0M0DT0H0M0S",
12+
"P1.5Y",
13+
"PT0.5H"
14+
],
15+
"x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE",
16+
"type": "string",
17+
"allOf": [
18+
{
19+
"not": {
20+
"const": "P"
21+
}
22+
},
23+
{
24+
"not": {
25+
"const": "PT"
26+
}
27+
}
28+
],
29+
"anyOf": [
30+
{
31+
"$comment": "Date-only: Years with decimal (lowest order)",
32+
"pattern": "^P[0-9]+(?:\\.[0-9]+)?Y$"
33+
},
34+
{
35+
"$comment": "Date-only: Years (integer) + Months with decimal (lowest order)",
36+
"pattern": "^P[0-9]+Y[0-9]+(?:\\.[0-9]+)?M$"
37+
},
38+
{
39+
"$comment": "Date-only: Years (integer) + Months (integer) + Days with decimal (lowest order)",
40+
"pattern": "^P[0-9]+Y[0-9]+M[0-9]+(?:\\.[0-9]+)?D$"
41+
},
42+
{
43+
"$comment": "Date-only: Months with decimal (lowest order)",
44+
"pattern": "^P[0-9]+(?:\\.[0-9]+)?M$"
45+
},
46+
{
47+
"$comment": "Date-only: Months (integer) + Days with decimal (lowest order)",
48+
"pattern": "^P[0-9]+M[0-9]+(?:\\.[0-9]+)?D$"
49+
},
50+
{
51+
"$comment": "Date-only: Days with decimal (lowest order)",
52+
"pattern": "^P[0-9]+(?:\\.[0-9]+)?D$"
53+
},
54+
{
55+
"$comment": "Time-only: Hours with decimal (lowest order)",
56+
"pattern": "^PT[0-9]+(?:\\.[0-9]+)?H$"
57+
},
58+
{
59+
"$comment": "Time-only: Hours (integer) + Minutes with decimal (lowest order)",
60+
"pattern": "^PT[0-9]+H[0-9]+(?:\\.[0-9]+)?M$"
61+
},
62+
{
63+
"$comment": "Time-only: Hours (integer) + Minutes (integer) + Seconds with decimal (lowest order)",
64+
"pattern": "^PT[0-9]+H[0-9]+M[0-9]+(?:\\.[0-9]+)?S$"
65+
},
66+
{
67+
"$comment": "Time-only: Minutes with decimal (lowest order)",
68+
"pattern": "^PT[0-9]+(?:\\.[0-9]+)?M$"
69+
},
70+
{
71+
"$comment": "Time-only: Minutes (integer) + Seconds with decimal (lowest order)",
72+
"pattern": "^PT[0-9]+M[0-9]+(?:\\.[0-9]+)?S$"
73+
},
74+
{
75+
"$comment": "Time-only: Seconds with decimal (lowest order)",
76+
"pattern": "^PT[0-9]+(?:\\.[0-9]+)?S$"
77+
},
78+
{
79+
"$comment": "Date+Time: Years + Hours with decimal (lowest order)",
80+
"pattern": "^P[0-9]+YT[0-9]+(?:\\.[0-9]+)?H$"
81+
},
82+
{
83+
"$comment": "Date+Time: Years + Hours (integer) + Minutes with decimal (lowest order)",
84+
"pattern": "^P[0-9]+YT[0-9]+H[0-9]+(?:\\.[0-9]+)?M$"
85+
},
86+
{
87+
"$comment": "Date+Time: Years + Hours (integer) + Minutes (integer) + Seconds with decimal (lowest order)",
88+
"pattern": "^P[0-9]+YT[0-9]+H[0-9]+M[0-9]+(?:\\.[0-9]+)?S$"
89+
},
90+
{
91+
"$comment": "Date+Time: Years + Minutes with decimal (lowest order)",
92+
"pattern": "^P[0-9]+YT[0-9]+(?:\\.[0-9]+)?M$"
93+
},
94+
{
95+
"$comment": "Date+Time: Years + Minutes (integer) + Seconds with decimal (lowest order)",
96+
"pattern": "^P[0-9]+YT[0-9]+M[0-9]+(?:\\.[0-9]+)?S$"
97+
},
98+
{
99+
"$comment": "Date+Time: Years + Seconds with decimal (lowest order)",
100+
"pattern": "^P[0-9]+YT[0-9]+(?:\\.[0-9]+)?S$"
101+
},
102+
{
103+
"$comment": "Date+Time: Years (integer) + Months + Hours with decimal (lowest order)",
104+
"pattern": "^P[0-9]+Y[0-9]+MT[0-9]+(?:\\.[0-9]+)?H$"
105+
},
106+
{
107+
"$comment": "Date+Time: Years (integer) + Months + Hours (integer) + Minutes with decimal (lowest order)",
108+
"pattern": "^P[0-9]+Y[0-9]+MT[0-9]+H[0-9]+(?:\\.[0-9]+)?M$"
109+
},
110+
{
111+
"$comment": "Date+Time: Years (integer) + Months + Hours (integer) + Minutes (integer) + Seconds with decimal (lowest order)",
112+
"pattern": "^P[0-9]+Y[0-9]+MT[0-9]+H[0-9]+M[0-9]+(?:\\.[0-9]+)?S$"
113+
},
114+
{
115+
"$comment": "Date+Time: Years (integer) + Months + Minutes with decimal (lowest order)",
116+
"pattern": "^P[0-9]+Y[0-9]+MT[0-9]+(?:\\.[0-9]+)?M$"
117+
},
118+
{
119+
"$comment": "Date+Time: Years (integer) + Months + Minutes (integer) + Seconds with decimal (lowest order)",
120+
"pattern": "^P[0-9]+Y[0-9]+MT[0-9]+M[0-9]+(?:\\.[0-9]+)?S$"
121+
},
122+
{
123+
"$comment": "Date+Time: Years (integer) + Months + Seconds with decimal (lowest order)",
124+
"pattern": "^P[0-9]+Y[0-9]+MT[0-9]+(?:\\.[0-9]+)?S$"
125+
},
126+
{
127+
"$comment": "Date+Time: Years (integer) + Months (integer) + Days + Hours with decimal (lowest order)",
128+
"pattern": "^P[0-9]+Y[0-9]+M[0-9]+DT[0-9]+(?:\\.[0-9]+)?H$"
129+
},
130+
{
131+
"$comment": "Date+Time: Years (integer) + Months (integer) + Days + Hours (integer) + Minutes with decimal (lowest order)",
132+
"pattern": "^P[0-9]+Y[0-9]+M[0-9]+DT[0-9]+H[0-9]+(?:\\.[0-9]+)?M$"
133+
},
134+
{
135+
"$comment": "Date+Time: Years (integer) + Months (integer) + Days + Hours (integer) + Minutes (integer) + Seconds with decimal (lowest order)",
136+
"pattern": "^P[0-9]+Y[0-9]+M[0-9]+DT[0-9]+H[0-9]+M[0-9]+(?:\\.[0-9]+)?S$"
137+
},
138+
{
139+
"$comment": "Date+Time: Years (integer) + Months (integer) + Days + Minutes with decimal (lowest order)",
140+
"pattern": "^P[0-9]+Y[0-9]+M[0-9]+DT[0-9]+(?:\\.[0-9]+)?M$"
141+
},
142+
{
143+
"$comment": "Date+Time: Years (integer) + Months (integer) + Days + Minutes (integer) + Seconds with decimal (lowest order)",
144+
"pattern": "^P[0-9]+Y[0-9]+M[0-9]+DT[0-9]+M[0-9]+(?:\\.[0-9]+)?S$"
145+
},
146+
{
147+
"$comment": "Date+Time: Years (integer) + Months (integer) + Days + Seconds with decimal (lowest order)",
148+
"pattern": "^P[0-9]+Y[0-9]+M[0-9]+DT[0-9]+(?:\\.[0-9]+)?S$"
149+
},
150+
{
151+
"$comment": "Date+Time: Months + Hours with decimal (lowest order)",
152+
"pattern": "^P[0-9]+MT[0-9]+(?:\\.[0-9]+)?H$"
153+
},
154+
{
155+
"$comment": "Date+Time: Months + Hours (integer) + Minutes with decimal (lowest order)",
156+
"pattern": "^P[0-9]+MT[0-9]+H[0-9]+(?:\\.[0-9]+)?M$"
157+
},
158+
{
159+
"$comment": "Date+Time: Months + Hours (integer) + Minutes (integer) + Seconds with decimal (lowest order)",
160+
"pattern": "^P[0-9]+MT[0-9]+H[0-9]+M[0-9]+(?:\\.[0-9]+)?S$"
161+
},
162+
{
163+
"$comment": "Date+Time: Months + Minutes with decimal (lowest order)",
164+
"pattern": "^P[0-9]+MT[0-9]+(?:\\.[0-9]+)?M$"
165+
},
166+
{
167+
"$comment": "Date+Time: Months + Minutes (integer) + Seconds with decimal (lowest order)",
168+
"pattern": "^P[0-9]+MT[0-9]+M[0-9]+(?:\\.[0-9]+)?S$"
169+
},
170+
{
171+
"$comment": "Date+Time: Months + Seconds with decimal (lowest order)",
172+
"pattern": "^P[0-9]+MT[0-9]+(?:\\.[0-9]+)?S$"
173+
},
174+
{
175+
"$comment": "Date+Time: Months (integer) + Days + Hours with decimal (lowest order)",
176+
"pattern": "^P[0-9]+M[0-9]+DT[0-9]+(?:\\.[0-9]+)?H$"
177+
},
178+
{
179+
"$comment": "Date+Time: Months (integer) + Days + Hours (integer) + Minutes with decimal (lowest order)",
180+
"pattern": "^P[0-9]+M[0-9]+DT[0-9]+H[0-9]+(?:\\.[0-9]+)?M$"
181+
},
182+
{
183+
"$comment": "Date+Time: Months (integer) + Days + Hours (integer) + Minutes (integer) + Seconds with decimal (lowest order)",
184+
"pattern": "^P[0-9]+M[0-9]+DT[0-9]+H[0-9]+M[0-9]+(?:\\.[0-9]+)?S$"
185+
},
186+
{
187+
"$comment": "Date+Time: Months (integer) + Days + Minutes with decimal (lowest order)",
188+
"pattern": "^P[0-9]+M[0-9]+DT[0-9]+(?:\\.[0-9]+)?M$"
189+
},
190+
{
191+
"$comment": "Date+Time: Months (integer) + Days + Minutes (integer) + Seconds with decimal (lowest order)",
192+
"pattern": "^P[0-9]+M[0-9]+DT[0-9]+M[0-9]+(?:\\.[0-9]+)?S$"
193+
},
194+
{
195+
"$comment": "Date+Time: Months (integer) + Days + Seconds with decimal (lowest order)",
196+
"pattern": "^P[0-9]+M[0-9]+DT[0-9]+(?:\\.[0-9]+)?S$"
197+
},
198+
{
199+
"$comment": "Date+Time: Days + Hours with decimal (lowest order)",
200+
"pattern": "^P[0-9]+DT[0-9]+(?:\\.[0-9]+)?H$"
201+
},
202+
{
203+
"$comment": "Date+Time: Days + Hours (integer) + Minutes with decimal (lowest order)",
204+
"pattern": "^P[0-9]+DT[0-9]+H[0-9]+(?:\\.[0-9]+)?M$"
205+
},
206+
{
207+
"$comment": "Date+Time: Days + Hours (integer) + Minutes (integer) + Seconds with decimal (lowest order)",
208+
"pattern": "^P[0-9]+DT[0-9]+H[0-9]+M[0-9]+(?:\\.[0-9]+)?S$"
209+
},
210+
{
211+
"$comment": "Date+Time: Days + Minutes with decimal (lowest order)",
212+
"pattern": "^P[0-9]+DT[0-9]+(?:\\.[0-9]+)?M$"
213+
},
214+
{
215+
"$comment": "Date+Time: Days + Minutes (integer) + Seconds with decimal (lowest order)",
216+
"pattern": "^P[0-9]+DT[0-9]+M[0-9]+(?:\\.[0-9]+)?S$"
217+
},
218+
{
219+
"$comment": "Date+Time: Days + Seconds with decimal (lowest order)",
220+
"pattern": "^P[0-9]+DT[0-9]+(?:\\.[0-9]+)?S$"
221+
}
222+
]
223+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
3+
"title": "ISO 8601-1:2019 Duration (Alternative Ordinal Basic Format)",
4+
"description": "A duration in alternative basic format with ordinal date P[YYYYDDD]T[HHMMSS] (§5.5.2.4)",
5+
"$comment": "https://www.iso.org/standard/70907.html",
6+
"examples": [ "P0002178T223355", "P0001001T000000", "P0001365T235959" ],
7+
"x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE",
8+
"type": "string",
9+
"pattern": "^P(?:[0-9]{4}|[+-][0-9]{5,})(?:0[0-9][1-9]|0[1-9][0-9]|[12][0-9]{2}|3[0-5][0-9]|36[0-6])T(?:[01][0-9]|2[0-3])(?:[0-5][0-9])(?:[0-5][0-9])$"
10+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
3+
"title": "ISO 8601-1:2019 Duration (Alternative Ordinal Extended Format)",
4+
"description": "A duration in alternative extended format with ordinal date P[YYYY-DDD]T[HH:MM:SS] (§5.5.2.4)",
5+
"$comment": "https://www.iso.org/standard/70907.html",
6+
"examples": [
7+
"P0002-178T22:33:55",
8+
"P0001-001T00:00:00",
9+
"P0001-365T23:59:59"
10+
],
11+
"x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE",
12+
"type": "string",
13+
"pattern": "^P(?:[0-9]{4}|[+-][0-9]{5,})-(?:0[0-9][1-9]|0[1-9][0-9]|[12][0-9]{2}|3[0-5][0-9]|36[0-6])T(?:[01][0-9]|2[0-3]):(?:[0-5][0-9]):(?:[0-5][0-9])$"
14+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
3+
"title": "ISO 8601-1:2019 Duration (Weeks Format)",
4+
"description": "A duration in complete representation with weeks format P[n]W (§5.5.2.2)",
5+
"$comment": "https://www.iso.org/standard/70907.html",
6+
"examples": [ "P10W", "P1W", "P52W", "P0W", "P1.5W" ],
7+
"x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE",
8+
"type": "string",
9+
"pattern": "^P[0-9]+(?:\\.[0-9]+)?W$"
10+
}

0 commit comments

Comments
 (0)