-
-
Notifications
You must be signed in to change notification settings - Fork 275
Expand file tree
/
Copy pathduration.json
More file actions
193 lines (193 loc) · 5.91 KB
/
duration.json
File metadata and controls
193 lines (193 loc) · 5.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
[
{
"description": "validation of duration strings",
"comment": "RFC 3339 Appendix A defines the ABNF grammar for ISO-8601 durations used by JSON Schema format 'duration'. These tests enforce only the syntax defined by that grammar.",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"format": "duration"
},
"tests": [
{
"description": "all string formats ignore integers",
"data": 12,
"valid": true
},
{
"description": "all string formats ignore floats",
"data": 13.7,
"valid": true
},
{
"description": "all string formats ignore objects",
"data": {},
"valid": true
},
{
"description": "all string formats ignore arrays",
"data": [],
"valid": true
},
{
"description": "all string formats ignore booleans",
"data": false,
"valid": true
},
{
"description": "all string formats ignore nulls",
"data": null,
"valid": true
},
{
"description": "a valid duration string",
"data": "P4DT12H30M5S",
"valid": true
},
{
"description": "an invalid duration string",
"data": "PT1D",
"valid": false
},
{
"description": "must start with P",
"data": "4DT12H30M5S",
"valid": false
},
{
"description": "no elements present",
"data": "P",
"valid": false
},
{
"description": "no time elements present",
"data": "P1YT",
"valid": false
},
{
"description": "no date or time elements present",
"data": "PT",
"valid": false
},
{
"description": "elements out of order",
"data": "P2D1Y",
"valid": false
},
{
"description": "missing time separator",
"data": "P1D2H",
"valid": false
},
{
"description": "time element in the date position",
"data": "P2S",
"valid": false
},
{
"description": "four years duration",
"data": "P4Y",
"valid": true
},
{
"description": "zero time, in seconds",
"data": "PT0S",
"valid": true
},
{
"description": "zero time, in days",
"data": "P0D",
"valid": true
},
{
"description": "one month duration",
"data": "P1M",
"valid": true
},
{
"description": "one minute duration",
"data": "PT1M",
"valid": true
},
{
"description": "one and a half days, in hours",
"data": "PT36H",
"valid": true
},
{
"description": "one and a half days, in days and hours",
"data": "P1DT12H",
"valid": true
},
{
"description": "two weeks",
"data": "P2W",
"valid": true
},
{
"description": "weeks cannot be combined with other units",
"data": "P1Y2W",
"valid": false
},
{
"description": "invalid non-ASCII '২' (a Bengali 2)",
"data": "P২Y",
"valid": false
},
{
"description": "element without unit",
"data": "P1",
"valid": false
},
{
"description": "all date and time components",
"data": "P1Y2M3DT4H5M6S",
"valid": true
},
{
"description": "date components only",
"data": "P1Y2M3D",
"valid": true
},
{
"description": "time components only",
"data": "PT1H2M3S",
"valid": true
},
{
"description": "month and day",
"data": "P1M2D",
"valid": true
},
{
"description": "hour and minute",
"data": "PT1H30M",
"valid": true
},
{
"description": "multi-digit values in all components",
"data": "P10Y10M10DT10H10M10S",
"valid": true
},
{
"description": "fractional duration is not allowed by RFC 3339 ABNF",
"comment": "numeric components use 1*DIGIT where DIGIT = %x30-39; '.' is not allowed",
"data": "PT0.5S",
"valid": false
},
{
"description": "leading whitespace is invalid",
"data": " P1D",
"valid": false
},
{
"description": "trailing whitespace is invalid",
"data": "P1D ",
"valid": false
},
{
"description": "empty string is invalid",
"data": "",
"valid": false
}
]
}
]