|
267 | 267 | let testsAll = {
|
268 | 268 | // ignore short in non-gregory
|
269 | 269 | // ignore med + long in ethiopic
|
| 270 | + "default": [ |
| 271 | + [dates.Jan, ['F','L','M','S']], |
| 272 | + [dates.May, ['F','L','M','S']], |
| 273 | + [dates.Jul, ['F','L','M','S']], |
| 274 | + [dates.Sep, ['F','L','M','S']], |
| 275 | + [dates.Nov, ['F','L','M','S']], |
| 276 | + ], |
270 | 277 | "ethiopic": [
|
271 | 278 | [dates.Jan, ['F']],
|
272 | 279 | [dates.May, ['F']],
|
273 | 280 | [dates.Jul, ['F']],
|
274 | 281 | [dates.Sep, ['F']],
|
275 | 282 | [dates.Nov, ['F']],
|
276 |
| - /* |
277 |
| - [dates.Feb, ['F']], |
278 |
| - [dates.Apr, ['F']], |
279 |
| - [dates.Mar, ['F']], |
280 |
| - [dates.Jun, ['F']], |
281 |
| - [dates.Aug, ['F']], |
282 |
| - [dates.Oct, ['F']], |
283 |
| - [dates.Dec, ['F']], |
284 |
| - */ |
285 |
| - ], |
286 |
| - "gregory": [ |
287 |
| - [dates.Jan, ['F','L','M','S']], |
288 |
| - [dates.May, ['F','L','M','S']], |
289 |
| - [dates.Jul, ['F','L','M','S']], |
290 |
| - [dates.Sep, ['F','L','M','S']], |
291 |
| - [dates.Nov, ['F','L','M','S']], |
292 |
| - /* |
293 |
| - [dates.Feb, ['F','L','M','S']], |
294 |
| - [dates.Apr, ['F','L','M','S']], |
295 |
| - [dates.Mar, ['F','L','M','S']], |
296 |
| - [dates.Jun, ['F','L','M','S']], |
297 |
| - [dates.Aug, ['F','L','M','S']], |
298 |
| - [dates.Oct, ['F','L','M','S']], |
299 |
| - [dates.Dec, ['F','L','M','S']], |
300 |
| - */ |
301 | 283 | ],
|
302 | 284 | "japanese": [
|
303 | 285 | [dates.Jan, ['F','M']],
|
304 | 286 | [dates.May, ['F','M']],
|
305 | 287 | [dates.Jul, ['F','M']],
|
306 | 288 | [dates.Sep, ['F','M']],
|
307 | 289 | [dates.Nov, ['F','M']],
|
308 |
| - /* |
309 |
| - [dates.Feb, ['F','M']], |
310 |
| - [dates.Apr, ['F','M']], |
311 |
| - [dates.Mar, ['F','M']], |
312 |
| - [dates.Jun, ['F','M']], |
313 |
| - [dates.Aug, ['F','M']], |
314 |
| - [dates.Oct, ['F','M']], |
315 |
| - [dates.Dec, ['F','M']], |
316 |
| - */ |
317 | 290 | ],
|
318 | 291 | }
|
319 | 292 |
|
320 | 293 | // matches
|
321 | 294 | let testsMin = {
|
322 | 295 | // 10 tests over 5 dates + 3 calendars with 3 options (use as few combos of options as possible)
|
323 | 296 | // this is pretty much it: can't inmprove and seems to always cover everything
|
324 |
| - "ethiopic": [ |
325 |
| - [dates.Jan, ["FM"]], |
326 |
| - ], |
327 |
| - "gregory": [ |
| 297 | + "default": [ |
328 | 298 | [dates.Jan, ["ML","SF"]],
|
329 | 299 | [dates.May, ["FM"]],
|
330 | 300 | [dates.Jul, ["ML"]],
|
331 | 301 | [dates.Sep, ["FM","SF"]],
|
332 | 302 | [dates.Nov, ["FM"]],
|
333 | 303 | ],
|
| 304 | + "ethiopic": [ |
| 305 | + [dates.Jan, ["FM"]], |
| 306 | + ], |
334 | 307 | "japanese": [
|
335 | 308 | [dates.Jan, ["FM"]],
|
336 | 309 | [dates.Sep, ["ML"]],
|
|
347 | 320 | aLocales.forEach(function(code) {
|
348 | 321 | let oTempData = {}
|
349 | 322 | Object.keys(tests).sort().forEach(function(cal) {
|
| 323 | + let src = cal |
350 | 324 | // calendar in options really slows this down
|
351 |
| - oTempData[cal] = {} |
352 | 325 | if (method == "all") {
|
353 |
| - // 1044 times |
354 |
| - try {oConst.DaF = Intl.DateTimeFormat(code, {calendar: cal, dateStyle: "full", timeStyle: "full", timeZone: tz})} catch(e) {} |
355 |
| - if ('ethiopic' !== cal) { |
356 |
| - // 696 times |
357 |
| - try {oConst.DaM = Intl.DateTimeFormat(code, {calendar: cal, dateStyle: "medium", timeStyle: "medium", timeZone: tz})} catch(e) {} |
358 |
| - if ('gregory' == cal) { |
359 |
| - // 348 times |
360 |
| - try {oConst.DaL = Intl.DateTimeFormat(code, {calendar: cal, dateStyle: "long", timeStyle: "long", timeZone: tz})} catch(e) {} |
361 |
| - try {oConst.DaS = Intl.DateTimeFormat(code, {calendar: cal, dateStyle: "short", timeStyle: "short", timeZone: tz})} catch(e) {} |
| 326 | + if ('default' == cal) { |
| 327 | + try {oConst.DaF = Intl.DateTimeFormat(code, {dateStyle: "full", timeStyle: "full", timeZone: tz})} catch(e) {} |
| 328 | + try {oConst.DaM = Intl.DateTimeFormat(code, {dateStyle: "medium", timeStyle: "medium", timeZone: tz})} catch(e) {} |
| 329 | + try {oConst.DaL = Intl.DateTimeFormat(code, {dateStyle: "long", timeStyle: "long", timeZone: tz})} catch(e) {} |
| 330 | + try {oConst.DaS = Intl.DateTimeFormat(code, {dateStyle: "short", timeStyle: "short", timeZone: tz})} catch(e) {} |
| 331 | + cal = oConst.DaF.resolvedOptions().calendar |
| 332 | + /* |
| 333 | + th = buddhist |
| 334 | + ar-sa = islamic-umalqura |
| 335 | + ckb-ir, fa, fa-af, lrc, msn, ps, uz-arab = persian |
| 336 | + */ |
| 337 | + } else { |
| 338 | + try {oConst.DaF = Intl.DateTimeFormat(code, {calendar: cal, dateStyle: "full", timeStyle: "full", timeZone: tz})} catch(e) {} |
| 339 | + if ('japanese' == cal) { |
| 340 | + try {oConst.DaM = Intl.DateTimeFormat(code, {calendar: cal, dateStyle: "medium", timeStyle: "medium", timeZone: tz})} catch(e) {} |
362 | 341 | }
|
363 | 342 | }
|
364 | 343 | } else {
|
365 |
| - // 1044 times |
366 |
| - try {oConst.DaFM = Intl.DateTimeFormat(code, {calendar: cal, dateStyle: "full", timeStyle: "medium", timeZone: tz})} catch(e) {} |
367 |
| - if ('ethiopic' !== cal) { |
368 |
| - // 696 times |
369 |
| - try {oConst.DaML = Intl.DateTimeFormat(code, {calendar: cal, dateStyle: "medium", timeStyle: "long", timeZone: tz})} catch(e) {} |
370 |
| - if ('gregory' == cal) { |
371 |
| - // 348 times |
372 |
| - try {oConst.DaSF = Intl.DateTimeFormat(code, {calendar: cal, dateStyle: "short", timeStyle: "full", timeZone: tz})} catch(e) {} |
| 344 | + if ('default' == cal) { |
| 345 | + try {oConst.DaFM = Intl.DateTimeFormat(code, {dateStyle: "full", timeStyle: "medium", timeZone: tz})} catch(e) {} |
| 346 | + try {oConst.DaML = Intl.DateTimeFormat(code, {dateStyle: "medium", timeStyle: "long", timeZone: tz})} catch(e) {} |
| 347 | + try {oConst.DaSF = Intl.DateTimeFormat(code, {dateStyle: "short", timeStyle: "full", timeZone: tz})} catch(e) {} |
| 348 | + cal = oConst.DaFM.resolvedOptions().calendar |
| 349 | + } else { |
| 350 | + try {oConst.DaFM = Intl.DateTimeFormat(code, {calendar: cal, dateStyle: "full", timeStyle: "medium", timeZone: tz})} catch(e) {} |
| 351 | + if ('japanese' == cal) { |
| 352 | + try {oConst.DaML = Intl.DateTimeFormat(code, {calendar: cal, dateStyle: "medium", timeStyle: "long", timeZone: tz})} catch(e) {} |
373 | 353 | }
|
374 | 354 | }
|
375 | 355 | }
|
| 356 | + oTempData[cal] = {} |
376 | 357 |
|
377 |
| - let array = tests[cal] |
| 358 | + let array = tests[src] |
378 | 359 | array.forEach(function(item) {
|
379 | 360 | let date = item[0]
|
380 | 361 | let aStyles = item[1]
|
381 | 362 | aStyles.forEach(function(opt) {
|
382 | 363 | if (oTempData[cal][opt] == undefined) {oTempData[cal][opt] = []}
|
383 | 364 | let constructor = 'Da'+ opt
|
384 | 365 | let formatter = oConst[constructor]
|
385 |
| - oTempData[cal][opt].push(formatter.format(date)) |
| 366 | + try { |
| 367 | + oTempData[cal][opt].push(formatter.format(date)) |
| 368 | + } catch(e) { |
| 369 | + oTempData[cal][opt].push('error') |
| 370 | + } |
386 | 371 | })
|
387 | 372 | })
|
388 | 373 | })
|
|
902 | 887 | ]
|
903 | 888 | list = list.concat(aListExtra)
|
904 | 889 | list = list.filter(function(item, position) {return list.indexOf(item) === position})
|
905 |
| - //list = ['en,english'] |
| 890 | + //list = ['ar-sa,arabic (saudi arabia)','en,english','fa,persian','th,thai',] |
906 | 891 |
|
907 | 892 | legend()
|
908 | 893 | if (isSupported) {
|
|
0 commit comments