@@ -262,6 +262,8 @@ const set_oIntlTests = () => new Promise(resolve => {
262
262
curS = { "symbol" : [ 1000 ] } ,
263
263
curB = { "name" : [ - 1 ] , "symbol" : [ 1000 ] } ,
264
264
curA = { "accounting" : [ - 1000 ] , "name" : [ - 1 ] , "symbol" : [ 1000 ] }
265
+ let dateA = new Date ( "January 18, 2023 1:00:00" ) ,
266
+ dateB = new Date ( "January 20, 2023 13:00:00" )
265
267
266
268
oIntlTests = {
267
269
"collation" : [
@@ -281,6 +283,30 @@ const set_oIntlTests = () => new Promise(resolve => {
281
283
"narrow" : [ "conjunction" , "disjunction" , "unit" ] ,
282
284
"short" : [ "conjunction" , "unit" ]
283
285
} ,
286
+ "datetimeformat" : {
287
+ "era" : {
288
+ // we need to control the date part so toLocaleString matches
289
+ "long" : [ { era : "long" , year : "numeric" , month : "numeric" , day : "numeric" } , [ new Date ( "-000001" ) ] ]
290
+ } ,
291
+ "fractionalSecondDigits" : {
292
+ "1" : [ { minute : "numeric" , second : 'numeric' , fractionalSecondDigits : 1 } , [ new Date ( "2022-06-11T01:12:34.5678Z" ) ] ]
293
+ } ,
294
+ "hour" : {
295
+ "numeric" : [ { hour : "numeric" } , [ dateA ] ] ,
296
+ } ,
297
+ "hourCycle" : {
298
+ "h11-2-digit" : [ { hour : "2-digit" , hourCycle : "h11" } , [ dateA ] ]
299
+ } ,
300
+ "month" : {
301
+ "narrow" : [ { month : "narrow" } , [ new Date ( "2023-11-15" ) ] ] ,
302
+ "short" : [ { month : "short" } , [ new Date ( "2023-01-15" ) , new Date ( "2023-09-15" ) ] ] ,
303
+ } ,
304
+ "weekday" : {
305
+ "long" : [ { weekday : "long" } , [ dateA , dateB ] ] ,
306
+ "narrow" : [ { weekday : "narrow" } , [ dateA , dateB ] ] ,
307
+ "short" : [ { weekday : "short" } , [ dateB ] ] ,
308
+ } ,
309
+ } ,
284
310
"notation" : {
285
311
"scientific" : { "decimal" : [ ] } ,
286
312
"standard" : { "decimal" : [ 0 / 0 , - 1000 , 987654 ] , "percent" : [ 1000 ] } ,
@@ -534,6 +560,18 @@ const get_locale_intl = () => new Promise(resolve => {
534
560
obj [ key ] [ s ] = data
535
561
} )
536
562
} )
563
+ } else if ( m == "datetimeformat" ) {
564
+ Object . keys ( tests ) . forEach ( function ( key ) {
565
+ obj [ key ] = { }
566
+ Object . keys ( tests [ key ] ) . forEach ( function ( s ) {
567
+ let option = tests [ key ] [ s ] [ 0 ]
568
+ let formatter = new Intl . DateTimeFormat ( code , option ) , data = [ ]
569
+ tests [ key ] [ s ] [ 1 ] . forEach ( function ( n ) {
570
+ value = ( isIntl ? formatter . format ( n ) : ( n ) . toLocaleString ( code , option ) ) ; data . push ( value )
571
+ } )
572
+ obj [ key ] [ s ] = data
573
+ } )
574
+ } )
537
575
} else if ( m == "dayperiod" ) {
538
576
Object . keys ( tests ) . forEach ( function ( key ) {
539
577
let formatter = new Intl . DateTimeFormat ( code , { hourCycle : "h12" , dayPeriod : key } ) , data = [ ]
@@ -660,10 +698,10 @@ const get_locale_intl = () => new Promise(resolve => {
660
698
}
661
699
const oMetrics = {
662
700
"intl" : [
663
- "collation" , "compact" , "currency" , "dayperiod" , "listformat" , "notation" , "numberformat_ftp" ,
701
+ "collation" , "compact" , "currency" , "datetimeformat" , " dayperiod", "listformat" , "notation" , "numberformat_ftp" ,
664
702
"pluralrules" , "relativetimeformat" , "relativetimeformat_ftp" , "sign" , "timezonename" , "unit"
665
703
] ,
666
- "tolocalestring" : [ "compact" , "currency" , "notation" , "sign" , "timezonename" , "unit" ] ,
704
+ "tolocalestring" : [ "compact" , "currency" , "datetimeformat" , " notation", "sign" , "timezonename" , "unit" ] ,
667
705
}
668
706
let t0 = nowFn ( ) , notation = ""
669
707
let METRIC , oString = { }
0 commit comments