-
Notifications
You must be signed in to change notification settings - Fork 75
Expand file tree
/
Copy pathtests.yaml
More file actions
510 lines (380 loc) · 12.5 KB
/
tests.yaml
File metadata and controls
510 lines (380 loc) · 12.5 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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
version: "0.1.0"
# All timestamps are Unix seconds.
# Reference timestamp for most timeago tests: 1704067200 (2024-01-01 00:00:00 UTC)
timeago:
- name: "just now - identical timestamps"
input: { timestamp: 1704067200, reference: 1704067200 }
output: "just now"
- name: "just now - 30 seconds ago"
input: { timestamp: 1704067170, reference: 1704067200 }
output: "just now"
- name: "just now - 44 seconds ago"
input: { timestamp: 1704067156, reference: 1704067200 }
output: "just now"
- name: "1 minute ago - 45 seconds"
input: { timestamp: 1704067155, reference: 1704067200 }
output: "1 minute ago"
- name: "1 minute ago - 89 seconds"
input: { timestamp: 1704067111, reference: 1704067200 }
output: "1 minute ago"
- name: "2 minutes ago - 90 seconds"
input: { timestamp: 1704067110, reference: 1704067200 }
output: "2 minutes ago"
- name: "30 minutes ago"
input: { timestamp: 1704065400, reference: 1704067200 }
output: "30 minutes ago"
- name: "44 minutes ago"
input: { timestamp: 1704064560, reference: 1704067200 }
output: "44 minutes ago"
- name: "1 hour ago - 45 minutes"
input: { timestamp: 1704064500, reference: 1704067200 }
output: "1 hour ago"
- name: "1 hour ago - 89 minutes"
input: { timestamp: 1704061860, reference: 1704067200 }
output: "1 hour ago"
- name: "2 hours ago - 90 minutes"
input: { timestamp: 1704061800, reference: 1704067200 }
output: "2 hours ago"
- name: "5 hours ago"
input: { timestamp: 1704049200, reference: 1704067200 }
output: "5 hours ago"
- name: "21 hours ago"
input: { timestamp: 1703991600, reference: 1704067200 }
output: "21 hours ago"
- name: "1 day ago - 22 hours"
input: { timestamp: 1703988000, reference: 1704067200 }
output: "1 day ago"
- name: "1 day ago - 35 hours"
input: { timestamp: 1703941200, reference: 1704067200 }
output: "1 day ago"
- name: "2 days ago - 36 hours"
input: { timestamp: 1703937600, reference: 1704067200 }
output: "2 days ago"
- name: "7 days ago"
input: { timestamp: 1703462400, reference: 1704067200 }
output: "7 days ago"
- name: "25 days ago"
input: { timestamp: 1701907200, reference: 1704067200 }
output: "25 days ago"
- name: "1 month ago - 26 days"
input: { timestamp: 1701820800, reference: 1704067200 }
output: "1 month ago"
- name: "1 month ago - 45 days"
input: { timestamp: 1700179200, reference: 1704067200 }
output: "1 month ago"
- name: "2 months ago - 46 days"
input: { timestamp: 1700092800, reference: 1704067200 }
output: "2 months ago"
- name: "6 months ago"
input: { timestamp: 1688169600, reference: 1704067200 }
output: "6 months ago"
- name: "11 months ago - 319 days"
input: { timestamp: 1676505600, reference: 1704067200 }
output: "11 months ago"
- name: "1 year ago - 320 days"
input: { timestamp: 1676419200, reference: 1704067200 }
output: "1 year ago"
- name: "1 year ago - 547 days"
input: { timestamp: 1656806400, reference: 1704067200 }
output: "1 year ago"
- name: "2 years ago - 548 days"
input: { timestamp: 1656720000, reference: 1704067200 }
output: "2 years ago"
- name: "5 years ago"
input: { timestamp: 1546300800, reference: 1704067200 }
output: "5 years ago"
- name: "future - in just now (30 seconds)"
input: { timestamp: 1704067230, reference: 1704067200 }
output: "just now"
- name: "future - in 1 minute"
input: { timestamp: 1704067260, reference: 1704067200 }
output: "in 1 minute"
- name: "future - in 5 minutes"
input: { timestamp: 1704067500, reference: 1704067200 }
output: "in 5 minutes"
- name: "future - in 1 hour"
input: { timestamp: 1704070200, reference: 1704067200 }
output: "in 1 hour"
- name: "future - in 3 hours"
input: { timestamp: 1704078000, reference: 1704067200 }
output: "in 3 hours"
- name: "future - in 1 day"
input: { timestamp: 1704150000, reference: 1704067200 }
output: "in 1 day"
- name: "future - in 2 days"
input: { timestamp: 1704240000, reference: 1704067200 }
output: "in 2 days"
- name: "future - in 1 month"
input: { timestamp: 1706745600, reference: 1704067200 }
output: "in 1 month"
- name: "future - in 1 year"
input: { timestamp: 1735689600, reference: 1704067200 }
output: "in 1 year"
duration:
- name: "zero seconds"
input: { seconds: 0 }
output: "0 seconds"
- name: "1 second"
input: { seconds: 1 }
output: "1 second"
- name: "45 seconds"
input: { seconds: 45 }
output: "45 seconds"
- name: "1 minute"
input: { seconds: 60 }
output: "1 minute"
- name: "1 minute 30 seconds"
input: { seconds: 90 }
output: "1 minute, 30 seconds"
- name: "2 minutes"
input: { seconds: 120 }
output: "2 minutes"
- name: "1 hour"
input: { seconds: 3600 }
output: "1 hour"
- name: "1 hour 1 minute"
input: { seconds: 3661 }
output: "1 hour, 1 minute"
- name: "1 hour 30 minutes"
input: { seconds: 5400 }
output: "1 hour, 30 minutes"
- name: "2 hours 30 minutes"
input: { seconds: 9000 }
output: "2 hours, 30 minutes"
- name: "1 day"
input: { seconds: 86400 }
output: "1 day"
- name: "1 day 2 hours"
input: { seconds: 93600 }
output: "1 day, 2 hours"
- name: "7 days"
input: { seconds: 604800 }
output: "7 days"
- name: "1 month (30 days)"
input: { seconds: 2592000 }
output: "1 month"
- name: "1 year (365 days)"
input: { seconds: 31536000 }
output: "1 year"
- name: "1 year 2 months"
input: { seconds: 36720000 }
output: "1 year, 2 months"
- name: "compact - 1h 1m"
input: { seconds: 3661, options: { compact: true } }
output: "1h 1m"
- name: "compact - 2h 30m"
input: { seconds: 9000, options: { compact: true } }
output: "2h 30m"
- name: "compact - 1d 2h"
input: { seconds: 93600, options: { compact: true } }
output: "1d 2h"
- name: "compact - 45s"
input: { seconds: 45, options: { compact: true } }
output: "45s"
- name: "compact - 0s"
input: { seconds: 0, options: { compact: true } }
output: "0s"
- name: "max_units 1 - hours only"
input: { seconds: 3661, options: { max_units: 1 } }
output: "1 hour"
- name: "max_units 1 - days only"
input: { seconds: 93600, options: { max_units: 1 } }
output: "1 day"
- name: "max_units 3"
input: { seconds: 93661, options: { max_units: 3 } }
output: "1 day, 2 hours, 1 minute"
- name: "compact max_units 1"
input: { seconds: 9000, options: { compact: true, max_units: 1 } }
output: "3h"
- name: "error - negative seconds"
input: { seconds: -100 }
error: true
parse_duration:
- name: "compact hours minutes"
input: "2h30m"
output: 9000
- name: "compact with space"
input: "2h 30m"
output: 9000
- name: "compact with comma"
input: "2h, 30m"
output: 9000
- name: "verbose"
input: "2 hours 30 minutes"
output: 9000
- name: "verbose with and"
input: "2 hours and 30 minutes"
output: 9000
- name: "verbose with comma and"
input: "2 hours, and 30 minutes"
output: 9000
- name: "decimal hours"
input: "2.5 hours"
output: 9000
- name: "decimal compact"
input: "1.5h"
output: 5400
- name: "single unit minutes verbose"
input: "90 minutes"
output: 5400
- name: "single unit minutes compact"
input: "90m"
output: 5400
- name: "single unit min"
input: "90min"
output: 5400
- name: "colon notation h:mm"
input: "2:30"
output: 9000
- name: "colon notation h:mm:ss"
input: "1:30:00"
output: 5400
- name: "colon notation with seconds"
input: "0:05:30"
output: 330
- name: "days verbose"
input: "2 days"
output: 172800
- name: "days compact"
input: "2d"
output: 172800
- name: "weeks verbose"
input: "1 week"
output: 604800
- name: "weeks compact"
input: "1w"
output: 604800
- name: "mixed verbose"
input: "1 day, 2 hours, and 30 minutes"
output: 95400
- name: "mixed compact"
input: "1d 2h 30m"
output: 95400
- name: "seconds only verbose"
input: "45 seconds"
output: 45
- name: "seconds compact s"
input: "45s"
output: 45
- name: "seconds compact sec"
input: "45sec"
output: 45
- name: "hours hr"
input: "2hr"
output: 7200
- name: "hours hrs"
input: "2hrs"
output: 7200
- name: "minutes mins"
input: "30mins"
output: 1800
- name: "case insensitive"
input: "2H 30M"
output: 9000
- name: "whitespace tolerance"
input: " 2 hours 30 minutes "
output: 9000
- name: "error - empty string"
input: ""
error: true
- name: "error - no units"
input: "hello world"
error: true
- name: "error - negative"
input: "-5 hours"
error: true
- name: "error - just number"
input: "42"
error: true
human_date:
# Reference: 2024-01-15 00:00:00 UTC (Monday)
# timestamp 1705276800
- name: "today"
input: { timestamp: 1705276800, reference: 1705276800 }
output: "Today"
- name: "today - same day different time"
input: { timestamp: 1705320000, reference: 1705276800 }
output: "Today"
- name: "yesterday"
input: { timestamp: 1705190400, reference: 1705276800 }
output: "Yesterday"
- name: "tomorrow"
input: { timestamp: 1705363200, reference: 1705276800 }
output: "Tomorrow"
- name: "last Sunday (1 day before Monday)"
input: { timestamp: 1705190400, reference: 1705276800 }
output: "Yesterday"
- name: "last Saturday (2 days ago)"
input: { timestamp: 1705104000, reference: 1705276800 }
output: "Last Saturday"
- name: "last Friday (3 days ago)"
input: { timestamp: 1705017600, reference: 1705276800 }
output: "Last Friday"
- name: "last Thursday (4 days ago)"
input: { timestamp: 1704931200, reference: 1705276800 }
output: "Last Thursday"
- name: "last Wednesday (5 days ago)"
input: { timestamp: 1704844800, reference: 1705276800 }
output: "Last Wednesday"
- name: "last Tuesday (6 days ago)"
input: { timestamp: 1704758400, reference: 1705276800 }
output: "Last Tuesday"
- name: "last Monday (7 days ago) - becomes date"
input: { timestamp: 1704672000, reference: 1705276800 }
output: "January 8"
- name: "this Tuesday (1 day future)"
input: { timestamp: 1705363200, reference: 1705276800 }
output: "Tomorrow"
- name: "this Wednesday (2 days future)"
input: { timestamp: 1705449600, reference: 1705276800 }
output: "This Wednesday"
- name: "this Thursday (3 days future)"
input: { timestamp: 1705536000, reference: 1705276800 }
output: "This Thursday"
- name: "this Sunday (6 days future)"
input: { timestamp: 1705795200, reference: 1705276800 }
output: "This Sunday"
- name: "next Monday (7 days future) - becomes date"
input: { timestamp: 1705881600, reference: 1705276800 }
output: "January 22"
- name: "same year different month"
input: { timestamp: 1709251200, reference: 1705276800 }
output: "March 1"
- name: "same year end of year"
input: { timestamp: 1735603200, reference: 1705276800 }
output: "December 31"
- name: "previous year"
input: { timestamp: 1672531200, reference: 1705276800 }
output: "January 1, 2023"
- name: "next year"
input: { timestamp: 1736121600, reference: 1705276800 }
output: "January 6, 2025"
date_range:
# Using 2024 dates
- name: "same day"
input: { start: 1705276800, end: 1705276800 }
output: "January 15, 2024"
- name: "same day different times"
input: { start: 1705276800, end: 1705320000 }
output: "January 15, 2024"
- name: "consecutive days same month"
input: { start: 1705276800, end: 1705363200 }
output: "January 15–16, 2024"
- name: "same month range"
input: { start: 1705276800, end: 1705881600 }
output: "January 15–22, 2024"
- name: "same year different months"
input: { start: 1705276800, end: 1707955200 }
output: "January 15 – February 15, 2024"
- name: "different years"
input: { start: 1703721600, end: 1705276800 }
output: "December 28, 2023 – January 15, 2024"
- name: "full year span"
input: { start: 1704067200, end: 1735603200 }
output: "January 1 – December 31, 2024"
- name: "swapped inputs - should auto-correct"
input: { start: 1705881600, end: 1705276800 }
output: "January 15–22, 2024"
- name: "multi-year span"
input: { start: 1672531200, end: 1735689600 }
output: "January 1, 2023 – January 1, 2025"