@@ -272,6 +272,12 @@ function set_oIntlTests() {
272
272
'short' : [ { weekday : 'short' } , [ dates . Fri ] ] ,
273
273
} ,
274
274
} ,
275
+ durationformat : {
276
+ 'digital' : { 'milliseconds' : 1 } ,
277
+ 'long' : { 'years' : 0 , 'seconds' : 2 , 'microseconds' : 1000 } ,
278
+ 'narrow' : { 'years' : 1 , 'months' : 2 , 'microseconds' : 1 } ,
279
+ 'short' : { 'days' : 2 , 'seconds' : 2 , 'nanoseconds' : 2 } ,
280
+ } ,
275
281
listformat : {
276
282
'narrow' : [ 'conjunction' , 'disjunction' , 'unit' ] ,
277
283
'short' : [ 'conjunction' , 'unit' ]
@@ -590,6 +596,13 @@ function get_locale_intl() {
590
596
tests [ key ] . forEach ( function ( item ) { data . push ( formatter . format ( dayperiods [ item ] ) ) } )
591
597
obj [ key ] = data
592
598
}
599
+ } else if ( 'durationformat' == m ) {
600
+ for ( let i = 0 ; i < testkeys . length ; i ++ ) {
601
+ let key = testkeys [ i ]
602
+ let yearformat = 'long' == key ? 'always' : 'auto' // long we want to force 0 for years
603
+ let formatter = new Intl . DurationFormat ( code , { style : key , yearsDisplay : yearformat } )
604
+ obj [ key ] = formatter . format ( tests [ key ] ) // there's only one test per style
605
+ }
593
606
} else if ( 'listformat' == m ) {
594
607
for ( let i = 0 ; i < testkeys . length ; i ++ ) {
595
608
let key = testkeys [ i ] , data = [ ]
@@ -716,8 +729,8 @@ function get_locale_intl() {
716
729
}
717
730
const oMetrics = {
718
731
intl : [
719
- 'collation' , 'compact' , 'currency' , ' datetimeformat', 'dayperiod' , 'listformat' , 'notation' , 'numberformat_ftp ',
720
- 'pluralrules' , 'relativetimeformat' , 'relativetimeformat_ftp' , 'sign' , 'timezonename' , 'unit'
732
+ 'collation' , 'compact' , 'currency' , 'durationformat' , ' datetimeformat', 'dayperiod' , 'listformat' , 'notation' ,
733
+ 'numberformat_ftp' , ' pluralrules', 'relativetimeformat' , 'relativetimeformat_ftp' , 'sign' , 'timezonename' , 'unit'
721
734
] ,
722
735
tolocalestring : [ 'compact' , 'currency' , 'datetimeformat' , 'notation' , 'sign' , 'timezonename' , 'unit' ] ,
723
736
}
0 commit comments