• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Copyright (c) 2007-2013 International Business Machines
2// Corporation and others. All Rights Reserved.
3format:table(nofallback) {
4    Info {
5        Description { "These are the data driven format tests" }
6        LongDescription {   "Data for data driven format tests." }
7    }
8    TestData {
9        TestDateFormatBasic {
10            Info {
11                Description { "Test data for format and parse :" }
12            }
13            Settings {
14                // options: 'format', or 'parse'.  One can be omitted if this is a 1 way test.
15                {
16                    Type { "date_format" }
17                },
18                {
19                    Type { "date_parse" }
20                },
21            }
22            Headers { "locale", "zone", "spec", "date", "str"}
23            // locale: locale including calendar type
24            // zone:   time zone name, or "" to not explicitly set zone
25            // spec:   either 'PATTERN=y mm h' etc, or 'DATE=SHORT,TIME=LONG'
26            // date:   either 'MILLIS=####' where #### is millis,
27            //        or a calendar spec ERA=0,YEAR=1, etc.. applied to the calendar type specified by the locale
28            //        or RELATIVE_MILLIS=### where ### is a signed value which is added to the current millis
29            //        or RELATIVE_ADD:DATE=1  which means that the field "DATE" will be added by +1 relative to current time,
30            //           and any other fields present will be set explicitly.
31            // str:   the expected unicode string
32            Cases {
33               {
34                    "en_US@calendar=gregorian",
35                    "",
36                    "DATE=SHORT,TIME=SHORT",
37                    "ERA=1,YEAR=2007,MONTH=AUGUST,DATE=8,HOUR_OF_DAY=18,MINUTE=54,SECOND=0",
38                    "8/8/07, 6:54 PM"
39               },
40               {
41                    "zh_TW@calendar=roc",
42                    "",
43                    "DATE=LONG",
44                    "ERA=1,YEAR=98,MONTH=0,DATE=24",
45                    "民國98年1月24日",
46               },
47               {
48                    //民國前2年1月24日 -> 1910-1-24
49                    "zh_TW@calendar=roc",
50                    "",
51                    "DATE=LONG",
52                    "ERA=0,YEAR=2,MONTH=0,DATE=24",
53                    "民國前2年1月24日",
54               },
55            }
56        }
57        TestFormatRelative {
58            Info {
59                Description { "relative format :" }
60            }
61            Settings {
62                {
63                    Type { "date_format" }
64                },
65            }
66            Headers { "locale", "zone", "spec", "date", "str"}
67            Cases {
68               {
69                    "en_US@calendar=gregorian",
70                    "",
71                    "DATE=RELATIVE_SHORT",
72                    "RELATIVE_ADD:DATE=1", // one day from now
73                    "tomorrow"
74               },
75               {
76                    "en_US@calendar=gregorian",
77                    "",
78                    "DATE=RELATIVE_SHORT",
79                    "RELATIVE_MILLIS=0", // today
80                    "today"
81               },
82               {
83                    "en_US@calendar=gregorian",
84                    "",
85                    "DATE=RELATIVE_SHORT",
86                    "RELATIVE_ADD:DATE=-1", // one day before now
87                    "yesterday"
88               },
89               // date only, out of relative range
90               {
91                    "en_US@calendar=gregorian",
92                    "GMT",
93                    "DATE=RELATIVE_FULL",
94                    "ERA=1,YEAR=2012,MONTH=OCTOBER,DATE=8,HOUR_OF_DAY=23,MINUTE=59,SECOND=0",
95                    "Monday, October 8, 2012"
96               },
97               // time only
98               {
99                    "en_US@calendar=gregorian",
100                    "GMT",
101                    "TIME=LONG",
102                    "ERA=1,YEAR=2012,MONTH=OCTOBER,DATE=8,HOUR_OF_DAY=23,MINUTE=59,SECOND=0",
103                    "11:59:00 PM GMT"
104               },
105               {
106                    "en_US@calendar=gregorian",
107                    "GMT",
108                    "TIME=LONG",
109                    "RELATIVE_ADD:DATE=-1,HOUR_OF_DAY=17,MINUTE=0,SECOND=0", // one day before now at specified time
110                    "5:00:00 PM GMT"
111               },
112               // normal formats, combined using 'at'
113               {
114                    "en_US@calendar=gregorian",
115                    "GMT",
116                    "DATE=RELATIVE_FULL,TIME=LONG",
117                    "ERA=1,YEAR=2012,MONTH=OCTOBER,DATE=8,HOUR_OF_DAY=23,MINUTE=59,SECOND=0",
118                    "Monday, October 8, 2012 at 11:59:00 PM GMT"
119               },
120               // normal formats, combined using ", "
121               {
122                    "en_US@calendar=gregorian",
123                    "GMT",
124                    "DATE=RELATIVE_MEDIUM,TIME=SHORT",
125                    "ERA=1,YEAR=2012,MONTH=OCTOBER,DATE=8,HOUR_OF_DAY=23,MINUTE=59,SECOND=0",
126                    "Oct 8, 2012, 11:59 PM"
127               },
128               // formats with relative day, combined using 'at'
129               {
130                    "en_US@calendar=gregorian",
131                    "GMT",
132                    "DATE=RELATIVE_FULL,TIME=LONG",
133                    "RELATIVE_ADD:DATE=-1,HOUR_OF_DAY=17,MINUTE=0,SECOND=0", // one day before now at specified time
134                    "yesterday at 5:00:00 PM GMT"
135               },
136               // formats with relative day, combined using ", "
137               {
138                    "en_US@calendar=gregorian",
139                    "GMT",
140                    "DATE=RELATIVE_MEDIUM,TIME=SHORT",
141                    "RELATIVE_ADD:DATE=-1,HOUR_OF_DAY=17,MINUTE=0,SECOND=0", // one day before now at specified time
142                    "yesterday, 5:00 PM"
143               },
144               // normal formats that have quoted literals, combined
145               {
146                    "pt@calendar=gregorian",
147                    "GMT",
148                    "DATE=RELATIVE_FULL,TIME=LONG",
149                    "ERA=1,YEAR=2012,MONTH=OCTOBER,DATE=8,HOUR_OF_DAY=23,MINUTE=59,SECOND=0",
150                    "segunda-feira, 8 de outubro de 2012 23:59:00 GMT"
151               },
152               // vi combined formats have time first
153               {
154                    "vi@calendar=gregorian",
155                    "GMT",
156                    "DATE=RELATIVE_LONG,TIME=MEDIUM",
157                    "ERA=1,YEAR=2012,MONTH=OCTOBER,DATE=8,HOUR_OF_DAY=23,MINUTE=59,SECOND=0",
158                    "23:59:00 Ngày 08 tháng 10 năm 2012"
159               },
160               {
161                    "vi@calendar=gregorian",
162                    "GMT",
163                    "DATE=RELATIVE_LONG,TIME=MEDIUM",
164                    "RELATIVE_ADD:DATE=-1,HOUR_OF_DAY=17,MINUTE=0,SECOND=0", // one day before now at specified time
165                    "17:00:00 Hôm qua"
166               },
167               // el combines formats using hyphen
168               {
169                    "el@calendar=gregorian",
170                    "GMT",
171                    "DATE=RELATIVE_LONG,TIME=MEDIUM",
172                    "ERA=1,YEAR=2012,MONTH=OCTOBER,DATE=8,HOUR_OF_DAY=23,MINUTE=59,SECOND=0",
173                    "8 Οκτωβρίου 2012 - 11:59:00 μ.μ."
174               },
175               {
176                    "el@calendar=gregorian",
177                    "GMT",
178                    "DATE=RELATIVE_LONG,TIME=MEDIUM",
179                    "RELATIVE_ADD:DATE=-1,HOUR_OF_DAY=17,MINUTE=0,SECOND=0", // one day before now at specified time
180                    "χθες - 5:00:00 μ.μ."
181               },
182              // other tests
183               {
184                    "mt_MT@calendar=gregorian",
185                    "",
186                    "DATE=RELATIVE_SHORT",
187                    "RELATIVE_ADD:DATE=1", // one day from now
188                    "Għada"
189               },
190               {
191                    "mt_MT@calendar=gregorian",
192                    "",
193                    "DATE=RELATIVE_SHORT",
194                    "RELATIVE_MILLIS=0", // today
195                    "Illum"
196               },
197               {
198                    "mt_MT@calendar=gregorian",
199                    "",
200                    "DATE=RELATIVE_SHORT",
201                    "RELATIVE_ADD:DATE=-1", // one day before now
202                    "Ilbieraħ"
203               },
204               {
205                    "ru",
206                    "",
207                    "DATE=RELATIVE_SHORT",
208                    "RELATIVE_ADD:DATE=-2", // 2 days ago
209                    "позавчера"
210               },
211            }
212        }
213        TestYearLengths {
214            Info {
215                Description { "Test data for multiple year lengths, y yy yyy yyyy yyyyy:" }
216            }
217            Settings {
218                // options: 'format', or 'parse'.  One can be omitted if this is a 1 way test.
219                {
220                    Type { "date_format" }
221                },
222// These are not round trippable, so do not parse.
223//                {
224//                    Type { "date_parse" }
225//                },
226            }
227            Headers { "locale", "zone", "spec", "date", "str"}
228            // locale: locale including calendar type
229            // zone:   time zone name, or "" to not explicitly set zone
230            // spec:   either 'PATTERN=y mm h' etc, or 'DATE=SHORT,TIME=LONG'
231            // date:   either 'MILLIS=####' where #### is millis,
232            //        or a calendar spec ERA=0,YEAR=1, etc.. applied to the calendar type specified by the locale
233            //        or RELATIVE_MILLIS=### where ### is a signed value which is added to the current millis
234            //        or RELATIVE_ADD:DATE=1  which means that the field "DATE" will be added by +1 relative to current time,
235            //           and any other fields present will be set explicitly.
236            // str:   the expected unicode string
237
238// from CLDR UTS 35:
239//Year  	y  	yy  	yyy  	yyyy  	yyyyy
240
241            Cases {
242//AD 1 	    1 	01 	001 	0001 	00001
243               {
244                    "en_US@calendar=gregorian",
245                    "",
246                    "PATTERN=G y",
247                    "YEAR=1",
248                    "AD 1"
249               },
250               {
251                    "en_US@calendar=gregorian",
252                    "",
253                    "PATTERN=G yy",
254                    "YEAR=1",
255                    "AD 01"
256               },
257               {
258                    "en_US@calendar=gregorian",
259                    "",
260                    "PATTERN=G yyy",
261                    "YEAR=1",
262                    "AD 001"
263               },
264               {
265                    "en_US@calendar=gregorian",
266                    "",
267                    "PATTERN=G yyyy",
268                    "YEAR=1",
269                    "AD 0001"
270               },
271               {
272                    "en_US@calendar=gregorian",
273                    "",
274                    "PATTERN=G yyyyy",
275                    "YEAR=1",
276                    "AD 00001"
277               },
278//AD 12 	12 	12 	012 	0012 	00012
279               {
280                    "en_US@calendar=gregorian",
281                    "",
282                    "PATTERN=G y",
283                    "YEAR=12",
284                    "AD 12"
285               },
286               {
287                    "en_US@calendar=gregorian",
288                    "",
289                    "PATTERN=G yy",
290                    "YEAR=12",
291                    "AD 12"
292               },
293               {
294                    "en_US@calendar=gregorian",
295                    "",
296                    "PATTERN=G yyy",
297                    "YEAR=12",
298                    "AD 012"
299               },
300               {
301                    "en_US@calendar=gregorian",
302                    "",
303                    "PATTERN=G yyyy",
304                    "YEAR=12",
305                    "AD 0012"
306               },
307               {
308                    "en_US@calendar=gregorian",
309                    "",
310                    "PATTERN=G yyyyy",
311                    "YEAR=12",
312                    "AD 00012"
313               },
314//AD 123 	123 	23 	123 	0123 	00123
315               {
316                    "en_US@calendar=gregorian",
317                    "",
318                    "PATTERN=G y",
319                    "YEAR=123",
320                    "AD 123"
321               },
322               {
323                    "en_US@calendar=gregorian",
324                    "",
325                    "PATTERN=G yy",
326                    "YEAR=123",
327                    "AD 23"
328               },
329               {
330                    "en_US@calendar=gregorian",
331                    "",
332                    "PATTERN=G yyy",
333                    "YEAR=123",
334                    "AD 123"
335               },
336               {
337                    "en_US@calendar=gregorian",
338                    "",
339                    "PATTERN=G yyyy",
340                    "YEAR=123",
341                    "AD 0123"
342               },
343               {
344                    "en_US@calendar=gregorian",
345                    "",
346                    "PATTERN=G yyyyy",
347                    "YEAR=123",
348                    "AD 00123"
349               },
350//AD 1234 	1234 	34 	1234 	1234 	01234
351               {
352                    "en_US@calendar=gregorian",
353                    "",
354                    "PATTERN=G y",
355                    "YEAR=1234",
356                    "AD 1234"
357               },
358               {
359                    "en_US@calendar=gregorian",
360                    "",
361                    "PATTERN=G yy",
362                    "YEAR=1234",
363                    "AD 34"
364               },
365               {
366                    "en_US@calendar=gregorian",
367                    "",
368                    "PATTERN=G yyy",
369                    "YEAR=1234",
370                    "AD 1234"
371               },
372               {
373                    "en_US@calendar=gregorian",
374                    "",
375                    "PATTERN=G yyyy",
376                    "YEAR=1234",
377                    "AD 1234"
378               },
379               {
380                    "en_US@calendar=gregorian",
381                    "",
382                    "PATTERN=G yyyyy",
383                    "YEAR=1234",
384                    "AD 01234"
385               },
386//AD 12345 	12345 	45 	12345 	12345 	12345
387               {
388                    "en_US@calendar=gregorian",
389                    "",
390                    "PATTERN=G y",
391                    "YEAR=12345",
392                    "AD 12345"
393               },
394               {
395                    "en_US@calendar=gregorian",
396                    "",
397                    "PATTERN=G yy",
398                    "YEAR=12345",
399                    "AD 45"
400               },
401               {
402                    "en_US@calendar=gregorian",
403                    "",
404                    "PATTERN=G yyy",
405                    "YEAR=12345",
406                    "AD 12345"
407               },
408               {
409                    "en_US@calendar=gregorian",
410                    "",
411                    "PATTERN=G yyyy",
412                    "YEAR=12345",
413                    "AD 12345"
414               },
415               {
416                    "en_US@calendar=gregorian",
417                    "",
418                    "PATTERN=G yyyyy",
419                    "YEAR=12345",
420                    "AD 12345"
421               },
422            }
423        }
424        TestConsistentPivot {
425            Info {
426                Description { "Test consistent pivot (parse/format) for multiple year lengths, y yy yyy yyyy yyyyy:" }
427            }
428            Settings {
429                // options: 'format', or 'parse'.  One can be omitted if this is a 1 way test.
430                {
431                    Type { "date_format" }
432                },
433                {
434                    Type { "date_parse" }
435                },
436            }
437            Headers { "locale", "zone", "spec", "date", "str"}
438            // locale: locale including calendar type
439            // zone:   time zone name, or "" to not explicitly set zone
440            // spec:   either 'PATTERN=y mm h' etc, or 'DATE=SHORT,TIME=LONG'
441            // date:   either 'MILLIS=####' where #### is millis,
442            //        or a calendar spec ERA=0,YEAR=1, etc.. applied to the calendar type specified by the locale
443            //        or RELATIVE_MILLIS=### where ### is a signed value which is added to the current millis
444            //        or RELATIVE_ADD:DATE=1  which means that the field "DATE" will be added by +1 relative to current time,
445            //           and any other fields present will be set explicitly.
446            // str:   the expected unicode string
447
448// from CLDR UTS 35:
449//Year  	y  	yy  	yyy  	yyyy  	yyyyy
450
451            Cases {
452//AD 1 	    1 	01 	001 	0001 	00001
453               {
454                    "en_US@calendar=gregorian",
455                    "",
456                    "PATTERN=G y",
457                    "YEAR=2008",
458                    "AD 2008"
459               },
460               {
461                    "en_US@calendar=gregorian",
462                    "",
463                    "PATTERN=G yy",
464                    "YEAR=2008",
465                    "AD 08"
466               },
467               {
468                    "en_US@calendar=gregorian",
469                    "",
470                    "PATTERN=G yyy",
471                    "YEAR=2008",
472                    "AD 2008"
473               },
474               {
475                    "en_US@calendar=gregorian",
476                    "",
477                    "PATTERN=G yyyy",
478                    "YEAR=2008",
479                    "AD 2008"
480               },
481               {
482                    "en_US@calendar=gregorian",
483                    "",
484                    "PATTERN=G yyyyy",
485                    "YEAR=2008",
486                    "AD 02008"
487               },
488
489				// Japanese
490               {
491                    "en_US@calendar=japanese",
492                    "",
493                    "PATTERN=G y",
494                    "YEAR=8",
495                    "Heisei 8"
496               },
497               {
498                    "en_US@calendar=japanese",
499                    "",
500                    "PATTERN=G yy",
501                    "YEAR=8",
502                    "Heisei 08"
503               },
504               {
505                    "en_US@calendar=japanese",
506                    "",
507                    "PATTERN=G yyy",
508                    "YEAR=8",
509                    "Heisei 008"
510               },
511               {
512                    "en_US@calendar=japanese",
513                    "",
514                    "PATTERN=G yyyy",
515                    "YEAR=8",
516                    "Heisei 0008"
517               },
518               {
519                    "en_US@calendar=japanese",
520                    "",
521                    "PATTERN=G yyyyy",
522                    "YEAR=8",
523                    "Heisei 00008"
524               },
525
526            }
527        }
528        TestHebrew{
529            Info {
530                Description { "Test Hebrew calendar:" }
531            }
532            Settings {
533                // options: 'format', or 'parse'.  One can be omitted if this is a 1 way test.
534                {
535                    Type { "date_format" }
536                },
537            }
538            Headers { "locale", "zone", "spec", "date", "str"}
539            // locale: locale including calendar type
540            // zone:   time zone name, or "" to not explicitly set zone
541            // spec:   either 'PATTERN=y mm h' etc, or 'DATE=SHORT,TIME=LONG'
542            // date:   either 'MILLIS=####' where #### is millis,
543            //        or a calendar spec ERA=0,YEAR=1, etc.. applied to the calendar type specified by the locale
544            //        or RELATIVE_MILLIS=### where ### is a signed value which is added to the current millis
545            //        or RELATIVE_ADD:DATE=1  which means that the field "DATE" will be added by +1 relative to current time,
546            //           and any other fields present will be set explicitly.
547            // str:   the expected unicode string
548
549            Cases {
550               {
551                    "en_US@calendar=hebrew",
552                    "",
553                    "DATE=FULL,TIME=FULL",
554                    "MILLIS=3076424179200000",
555                    "Friday, Heshvan 3, 103217 AM at 12:00:00 AM GMT-08:00"
556               },
557            }
558        }
559        TestMoreDateParse {
560            Info {
561                Description { "Additional date parse tests (may not
562               round/trip to format.)" }
563            }
564            Settings {
565                // options: 'format', or 'parse'.  One can be omitted if this is a 1 way test.
566                {
567                    Type { "date_parse" }
568                },
569            }
570            Headers { "locale", "zone", "spec", "date", "str"}
571            // locale: locale including calendar type
572            // zone:   time zone name, or "" to not explicitly set zone
573            // spec:   either 'PATTERN=y mm h' etc, or 'DATE=SHORT,TIME=LONG'
574            // date:   either 'MILLIS=####' where #### is millis,
575            //        or a calendar spec ERA=0,YEAR=1, etc.. applied to the calendar type specified by the locale
576            //        or RELATIVE_MILLIS=### where ### is a signed value which is added to the current millis
577            //        or RELATIVE_ADD:DATE=1  which means that the field "DATE" will be added by +1 relative to current time,
578            //           and any other fields present will be set explicitly.
579            // str:   the expected unicode string
580
581            Cases {
582               {
583                    "en_US@calendar=gregorian",
584                    "",
585                    "PATTERN=YYYYHHmmssEEEww",
586                    "YEAR=1999,HOUR_OF_DAY=4,MINUTE=5,SECOND=6,DAY_OF_WEEK=2,WEEK_OF_YEAR=4",
587               // won't roundtrip.
588                    "1998040506MON56"
589               }
590            }
591        }
592    }
593}
594