Skip to content

Commit b196bd6

Browse files
tweak.. MOAR entropy
use default calendar instead of gregory
1 parent 2a6aefb commit b196bd6

File tree

1 file changed

+44
-59
lines changed

1 file changed

+44
-59
lines changed

tests/dtfstyle.html

+44-59
Original file line numberDiff line numberDiff line change
@@ -267,70 +267,43 @@
267267
let testsAll = {
268268
// ignore short in non-gregory
269269
// 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+
],
270277
"ethiopic": [
271278
[dates.Jan, ['F']],
272279
[dates.May, ['F']],
273280
[dates.Jul, ['F']],
274281
[dates.Sep, ['F']],
275282
[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-
*/
301283
],
302284
"japanese": [
303285
[dates.Jan, ['F','M']],
304286
[dates.May, ['F','M']],
305287
[dates.Jul, ['F','M']],
306288
[dates.Sep, ['F','M']],
307289
[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-
*/
317290
],
318291
}
319292

320293
// matches
321294
let testsMin = {
322295
// 10 tests over 5 dates + 3 calendars with 3 options (use as few combos of options as possible)
323296
// 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": [
328298
[dates.Jan, ["ML","SF"]],
329299
[dates.May, ["FM"]],
330300
[dates.Jul, ["ML"]],
331301
[dates.Sep, ["FM","SF"]],
332302
[dates.Nov, ["FM"]],
333303
],
304+
"ethiopic": [
305+
[dates.Jan, ["FM"]],
306+
],
334307
"japanese": [
335308
[dates.Jan, ["FM"]],
336309
[dates.Sep, ["ML"]],
@@ -347,42 +320,54 @@
347320
aLocales.forEach(function(code) {
348321
let oTempData = {}
349322
Object.keys(tests).sort().forEach(function(cal) {
323+
let src = cal
350324
// calendar in options really slows this down
351-
oTempData[cal] = {}
352325
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) {}
362341
}
363342
}
364343
} 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) {}
373353
}
374354
}
375355
}
356+
oTempData[cal] = {}
376357

377-
let array = tests[cal]
358+
let array = tests[src]
378359
array.forEach(function(item) {
379360
let date = item[0]
380361
let aStyles = item[1]
381362
aStyles.forEach(function(opt) {
382363
if (oTempData[cal][opt] == undefined) {oTempData[cal][opt] = []}
383364
let constructor = 'Da'+ opt
384365
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+
}
386371
})
387372
})
388373
})
@@ -902,7 +887,7 @@
902887
]
903888
list = list.concat(aListExtra)
904889
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',]
906891

907892
legend()
908893
if (isSupported) {

0 commit comments

Comments
 (0)