Skip to content

Commit dfdafda

Browse files
ICU76 (#359)
1 parent 80815d2 commit dfdafda

16 files changed

+339
-417
lines changed

js/region.js

+44-38
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ function set_oIntlTests() {
224224
FSD: new Date('2023-06-11T01:12:34.5678'), // no Z
225225
Era: new Date(-1, -11, -30),
226226
Jan: new Date('2023-01-15'),
227+
Jun: new Date("2023-06-15"),
227228
Sep: new Date('2023-09-15'),
228229
Nov: new Date('2023-11-15'),
229230
Wed: new Date('January 18, 2023 1:00:00'), // doubles as hour 1
@@ -243,7 +244,7 @@ function set_oIntlTests() {
243244
},
244245
compact: {
245246
'long': [0/0, 1000, 2e6, 6.6e12, 7e15],
246-
'short': [-1100000000],
247+
'short': [-1100000000, -1000],
247248
},
248249
currency: {'KES': curB, 'MOP': curS, 'USD': curA, 'XXX': curN,},
249250
dayperiod: {'long': [8,22], 'narrow': [8,15], 'short': [12,15,18]},
@@ -263,7 +264,7 @@ function set_oIntlTests() {
263264
},
264265
month: {
265266
'narrow': [{month: 'narrow'}, [dates.Nov] ],
266-
'short': [{month: 'short'}, [dates.Jan, dates.Sep]],
267+
'short': [{month: 'short'}, [dates.Jan, dates.Jun, dates.Sep]],
267268
},
268269
weekday: {
269270
'long': [{weekday: 'long'}, [dates.Wed, dates.Fri]],
@@ -749,46 +750,51 @@ function get_locale_intl() {
749750
}
750751

751752
function get_locale_resolvedoptions(METRIC) {
752-
753-
function get_metric(m, code) {
754-
let r
755-
let type = 'string'
756-
try {
757-
// collator
758-
if (m == 'caseFirst') {r = Intl.Collator(code).resolvedOptions().caseFirst
759-
} else if (m == 'ignorePunctuation') {type = 'boolean'; r = Intl.Collator(code).resolvedOptions().ignorePunctuation
760-
// DTF
761-
} else if (m == 'calendar') {r = Intl.DateTimeFormat(code).resolvedOptions().calendar
762-
} else if (m == 'day') {r = Intl.DateTimeFormat(code).resolvedOptions().day
763-
} else if (m == 'hourCycle') {r = Intl.DateTimeFormat(code, {hour: 'numeric'}).resolvedOptions().hourCycle
764-
} else if (m == 'month') {r = Intl.DateTimeFormat(code).resolvedOptions().month
765-
} else if (m == 'numberingSystem_dtf') {r = Intl.DateTimeFormat(code).resolvedOptions().numberingSystem
766-
// NF
767-
} else if (m == 'numberingSystem_nf') {r = new Intl.NumberFormat(code).resolvedOptions().numberingSystem
768-
// PR
769-
} else if (m == 'pluralCategories') {r = new Intl.PluralRules(code).resolvedOptions().pluralCategories.join(', ')
770-
// RTF
771-
} else if (m == 'numberingSystem_rtf') {r = new Intl.RelativeTimeFormat(code).resolvedOptions().numberingSystem
753+
// already sorted
754+
let oTests = {
755+
collator: ['caseFirst'],
756+
datetimeformat: ['calendar','day','hourcycle','month','numberingSystem'],
757+
pluralrules: ['pluralCategories'],
758+
}
759+
function get_metrics(code) {
760+
let tmpData = {}
761+
for (const k of Object.keys(oTests)) {
762+
tmpData[k] = {}
763+
let metrics = oTests[k]
764+
try {
765+
// set constructor
766+
let constructor
767+
if ('collator' == k) {constructor = Intl.Collator(code).resolvedOptions()
768+
} else if ('datetimeformat' == k) {constructor = Intl.DateTimeFormat(code).resolvedOptions()
769+
} else if ('pluralrules' == k) {constructor = new Intl.PluralRules(code).resolvedOptions()
770+
}
771+
// get values
772+
metrics.forEach(function(m) {
773+
try {
774+
let value
775+
if ('hourcycle' == m) {
776+
value = Intl.DateTimeFormat(code, {hour: "numeric"}).resolvedOptions().hourCycle
777+
} else if ('pluralCategories' == m) {
778+
value = constructor[m].join(', ')
779+
} else {
780+
value = constructor[m]
781+
}
782+
tmpData[k][m] = value
783+
} catch(e) {
784+
log_error(4, METRIC +'_'+ k + '_'+ m, e)
785+
tmpData[k][m] = zErr
786+
}
787+
})
788+
} catch(e) {
789+
log_error(4, METRIC +'_'+ k, e)
790+
tmpData[k] = zErr
772791
}
773-
if (runST) {r = undefined}
774-
let typeCheck = typeFn(r)
775-
if (type !== typeCheck) {throw zErrType + typeCheck}
776-
return r
777-
} catch(e) {
778-
log_error(4, METRIC +'_'+ m, e)
779-
return zErr
780792
}
793+
return tmpData
781794
}
782795

783-
let oData = {}, oCheck = {}, notation = locale_red
784-
let metrics = [
785-
'calendar','caseFirst','day','hourCycle','ignorePunctuation','month',
786-
'numberingSystem_dtf','numberingSystem_nf','numberingSystem_rtf','pluralCategories',
787-
]
788-
metrics.forEach(function(m) {oData[m] = get_metric(m, undefined)})
789-
if (isLocaleValid) {
790-
metrics.forEach(function(m) {oCheck[m] = get_metric(m, isLocaleValue)})
791-
}
796+
let oData = get_metrics(undefined), oCheck = {}, notation = locale_red
797+
if (isLocaleValid) {oCheck = get_metrics(isLocaleValue)}
792798
let hash = mini(oData), btnDiff = ''
793799
if (isLocaleValid) {
794800
if (hash == mini(oCheck)) {

tests/collation.html

+6-8
Original file line numberDiff line numberDiff line change
@@ -523,16 +523,13 @@
523523
let ff = ""
524524
// don't notate unless it's our own preset
525525
if (isFF && thisHash == exampleHash) {
526-
// only hash notate if 102+
527-
let is102 = (CanvasRenderingContext2D.prototype.hasOwnProperty("direction") && Array(1).includes())
528-
if (is102) {
529-
if (localesHash == "a7d80e7c") {ff = "110+"
530-
} else if (localesHash == "ec4e8131") {ff = "102-109"
531-
} else {ff = zNEW}
532-
if (ff !== zNEW) {ff = s14 +"[FF"+ ff + "]"+ sc}
526+
// notate new if 128+
527+
if (isVer > 127) {
528+
if (localesHash == "a7d80e7c") { // FF128+
529+
} else {localesHash += ' '+ zNEW}
533530
}
534531
}
535-
strItem = s12 +"locales: "+ sc + localesHash +" "+ ff +"<br>"
532+
strItem = s12 +"locales: "+ sc + localesHash +"<br>"
536533
output.push(strItem)
537534

538535
// details
@@ -554,6 +551,7 @@
554551
Promise.all([
555552
get_globals()
556553
]).then(function(){
554+
get_isVer()
557555
// add additional locales to core locales for this test
558556
let aListExtra = [
559557
"bs-cyrl,bosnian (cyrillic)",

tests/dtf.html

+20-16
Original file line numberDiff line numberDiff line change
@@ -243,12 +243,13 @@
243243
],
244244
"month": [
245245
[new Date("2023-01-15"), {"short": {month: "short"}}],
246+
[new Date("2023-06-15"), {"short": {month: "short"}}],
246247
[new Date("2023-09-15"), {"short": {month: "short"}}],
247248
[new Date("2023-11-15"), {"narrow": {month: "narrow"}}],
248249
],
249250
"weekday": [
250251
[dateA, {"narrow": {weekday: "narrow"}, "long": {weekday: "long"}}],
251-
[dateB, {"short": {weekday: "short"}, "narrow": {weekday: "narrow"}, "long": {weekday: "long"}}]
252+
[dateB, {"short": {weekday: "short"}, "narrow": {weekday: "narrow"}, "long": {weekday: "long"}}],
252253
],
253254
}
254255

@@ -278,6 +279,7 @@
278279
try {oConst.WeL = new Intl.DateTimeFormat(code, {weekday: "long"})} catch(e) {}
279280
try {oConst.MoS = new Intl.DateTimeFormat(code, {month: "short"})} catch(e) {}
280281
try {oConst.MoN = new Intl.DateTimeFormat(code, {month: "narrow"})} catch(e) {}
282+
//try {oConst.MoL = new Intl.DateTimeFormat(code, {month: "long"})} catch(e) {}
281283
try {oConst.HoN = new Intl.DateTimeFormat(code, {hour: "numeric"})} catch(e) {}
282284
try {oConst.HoH = new Intl.DateTimeFormat(code, {hour: "2-digit", hourCycle: "h11"})} catch(e) {}
283285
try {oConst.ErL = new Intl.DateTimeFormat(code, {era: "long"})} catch(e) {}
@@ -361,21 +363,18 @@
361363
let localesMatch = ""
362364
if (method == "all") {
363365
localesHashAll = localesHash
364-
if (isFF) {
365-
// only hash notate if 115+
366-
let is115 = (CanvasRenderingContext2D.prototype.hasOwnProperty("letterSpacing"))
367-
if (is115) {
368-
// track FF version changes
369-
// ignore if non-supported used, which return same as undefined = user's resolved options
370-
// results
371-
if (resultsHash == "80c3fd6b") {resultsHash += s14 +" [FF127+]"+ sc
372-
} else if (resultsHash == "72c1b3f5") {resultsHash += s14 +" [FF115-126]"+ sc
373-
} else {resultsHash += ' '+ zNEW
374-
}
375-
// locales
376-
if (localesHash == "86c0f15f") {localesHash += s14 +" [FF115+]"+ sc
377-
} else {localesHash += ' '+ zNEW
378-
}
366+
// notate new if 128+
367+
if (isVer > 127) {
368+
// ignore if non-supported used, which return same as undefined = user's resolved options
369+
// results
370+
if (resultsHash == "b33bb78b") { // FF134+
371+
} else if (resultsHash == "0095da8a") { // FF128-133
372+
} else {resultsHash += ' '+ zNEW
373+
}
374+
// locales
375+
if (localesHash == "eef79c58") { // FF134+: 310
376+
} else if (localesHash == "0c9d407a") { // FF128-133: 301
377+
} else {localesHash += ' '+ zNEW
379378
}
380379
}
381380
} else if (method == "min") {
@@ -422,6 +421,7 @@
422421
Promise.all([
423422
get_globals()
424423
]).then(function(){
424+
get_isVer()
425425
try {
426426
// pointless if we can't use the feature being tested: FF58+
427427
let test = new Intl.DateTimeFormat("en").formatToParts(new Date)
@@ -457,13 +457,16 @@
457457
"en-ca,english (canada)",
458458
"en-ch,english (switzerland)",
459459
"en-dk,english (denmark)",
460+
"en-gb,english (united kingdom)",
460461
"en-ie,english (ireland)",
461462
"en-il,english (israel)",
462463
"es-419,spanish (latin america and the caribbean)",
463464
"es-ar,spanish (argentina)",
465+
"es-bz,spanish (belize)",
464466
"es-cl,spanish (chile)",
465467
"es-co,spanish (colombia)",
466468
"es-do,spanish (dominican republic)",
469+
"es-mx,spanish (mexico)",
467470
"es-pe,spanish (peru)",
468471
"es-ph,spanish (philippines)",
469472
"es-uy,spanish (uruguay)",
@@ -480,6 +483,7 @@
480483
"hi-latn,hindi (latin)",
481484
"hr-ba,croatian (bosnia & herzegovina)",
482485
"it-ch,italian (switzerland)",
486+
"kok-latn,konkani (latin)",
483487
"ks-deva,kashmiri (devanagari)",
484488
"lrc-iq,northern luri (iraq)",
485489
"ms-bn,malay (brunei)",

tests/dtfdayperiod.html

+13-13
Original file line numberDiff line numberDiff line change
@@ -267,19 +267,17 @@
267267
let localesMatch = ""
268268
if (method == "all") {
269269
localesHashAll = localesHash
270-
if (isFF) {
271-
// only hash notate if 115+
272-
let is115 = (CanvasRenderingContext2D.prototype.hasOwnProperty("letterSpacing"))
273-
if (is115) {
274-
// track FF version changes
275-
// results
276-
if (resultsHash == "fe9c0751") {resultsHash += s14 +" [FF115+]"+ sc
277-
} else {resultsHash += zNEW
278-
}
279-
// locales
280-
if (localesHash == "6b3f4b76") {localesHash += s14 +" [FF115+]"+ sc
281-
} else if (isFF) {localesHash += zNEW
282-
}
270+
// notate new if 128+
271+
if (isVer > 127) {
272+
// results
273+
if (resultsHash == "726a3f3e") { // FF134+
274+
} else if (resultsHash == "a1b85e7a") { // FF128-133
275+
} else {resultsHash += ' '+ zNEW
276+
}
277+
// locales
278+
if (localesHash == "7f0661b3") { // FF134+: 213
279+
} else if (localesHash == "5c9553ed") { // FF128-133: 210
280+
} else if (isFF) {localesHash += ' '+ zNEW
283281
}
284282
}
285283
} else if (method == "custom") {
@@ -367,6 +365,7 @@
367365
Promise.all([
368366
get_globals()
369367
]).then(function(){
368+
get_isVer()
370369
reset_custom("min")
371370
// add additional locales to core locales for this test
372371
let aListExtra = [
@@ -386,6 +385,7 @@
386385
"fr-ch,french (switzerland)",
387386
"fr-sn,french (senegal)",
388387
"hi-latn,hindi (latin)",
388+
"kok-latn,konkani (latin)",
389389
"ks-deva,kashmiri (devanagari)",
390390
"pt-pt,portuguese (portugal)",
391391
"ro-md,romanian (moldova)",

tests/dtflistformat.html

+12-13
Original file line numberDiff line numberDiff line change
@@ -243,19 +243,17 @@
243243
let localesMatch = ""
244244
if (method == "all") {
245245
localesHashAll = localesHash
246-
if (isFF) {
247-
// only hash notate if 115+
248-
let is115 = (CanvasRenderingContext2D.prototype.hasOwnProperty("letterSpacing"))
249-
if (is115) {
250-
// track FF version changes
251-
// results
252-
if (resultsHash == "c967767a") {resultsHash += s14 +" [FF115+]"+ sc
253-
} else {resultsHash += zNEW
254-
}
255-
// locales
256-
if (localesHash == "5520ad5a") {localesHash += s14 +" [FF115+]"+ sc
257-
} else if (isFF) {localesHash += zNEW
258-
}
246+
// notate new if 128+
247+
if (isVer > 127) {
248+
// results
249+
if (resultsHash == "86d07210") { // FF134+
250+
} else if (resultsHash == "c967767a") { // FF128-133
251+
} else {resultsHash += ' '+ zNEW
252+
}
253+
// locales
254+
if (localesHash == "b7e10450") { // FF134+: 145
255+
} else if (localesHash == "5520ad5a") { // FF128-133: 140
256+
} else if (isFF) {localesHash += ' '+ zNEW
259257
}
260258
}
261259
} else if (method == "custom") {
@@ -325,6 +323,7 @@
325323
Promise.all([
326324
get_globals()
327325
]).then(function(){
326+
get_isVer()
328327
// support
329328
try {
330329
let test = new Intl.ListFormat(undefined, {style: "short", type: "conjunction"}).format(["a","b","c"])

0 commit comments

Comments
 (0)