@@ -9,48 +9,35 @@ description: >
9
9
info: |
10
10
12.4.5 Intl.DateTimeFormat.prototype.resolvedOptions()
11
11
12
- 12.1.1 InitializeDateTimeFormat ( dateTimeFormat, locales, options )
13
- 29. If dateTimeFormat.[[Hour]] is not undefined, then
14
- a. Let hcDefault be dataLocaleData.[[hourCycle]].
15
- b. Let hc be dateTimeFormat.[[HourCycle]].
16
- c. If hc is null, then
17
- i. Set hc to hcDefault.
18
- d. If hour12 is not undefined, then
19
- i. If hour12 is true, then
20
- 1. If hcDefault is "h11" or "h23", then
21
- a. Set hc to "h11".
22
- 2. Else,
23
- a. Set hc to "h12".
24
- ii. Else,
25
- 1. Assert: hour12 is false.
26
- 2. If hcDefault is "h11" or "h23", then
27
- a. Set hc to "h23".
28
- 3. Else,
29
- a. Set hc to "h24".
30
- e. Set dateTimeFormat.[[HourCycle]] to hc.
31
-
12
+ 12.1.1 InitializeDateTimeFormat ( dateTimeFormat, locales, options)
13
+ 23. Let dataLocaleData be localeData.[[<dataLocale>]].
14
+ 24. If hour12 is true, then
15
+ a. Let hc be dataLocaleData.[[hourCycle12]].
16
+ 25. Else if hour12 is false, then
17
+ a. Let hc be dataLocaleData.[[hourCycle24]].
18
+ 26. Else,
19
+ a. Assert: hour12 is undefined.
20
+ b. Let hc be r.[[hc]].
21
+ c. If hc is null, set hc to dataLocaleData.[[hourCycle]].
22
+ 27. Set dateTimeFormat.[[HourCycle]] to hc.
23
+
32
24
locale: [en, fr, it, ja, zh, ko, ar, hi]
33
25
---*/
34
26
35
27
let locales = [ "en" , "fr" , "it" , "ja" , "zh" , "ko" , "ar" , "hi" ] ;
36
28
37
- locales . forEach ( function ( locale ) {
38
- let hcDefault = ( new Intl . DateTimeFormat ( locale , { hour : "numeric" } ) )
39
- . resolvedOptions ( ) . hourCycle ;
40
- if ( hcDefault == "h11" || hcDefault == "h23" ) {
41
- assert . sameValue ( "h11" ,
42
- ( new Intl . DateTimeFormat ( locale , { hour : "numeric" , hour12 : true } ) )
43
- . resolvedOptions ( ) . hourCycle ) ;
44
- assert . sameValue ( "h23" ,
45
- ( new Intl . DateTimeFormat ( locale , { hour : "numeric" , hour12 : false } ) )
46
- . resolvedOptions ( ) . hourCycle ) ;
47
- } else {
48
- assert . sameValue ( true , hcDefault == "h12" || hcDefault == "h24" )
49
- assert . sameValue ( "h12" ,
50
- ( new Intl . DateTimeFormat ( locale , { hour : "numeric" , hour12 : true } ) )
51
- . resolvedOptions ( ) . hourCycle ) ;
52
- assert . sameValue ( "h24" ,
53
- ( new Intl . DateTimeFormat ( locale , { hour : "numeric" , hour12 : false } ) )
54
- . resolvedOptions ( ) . hourCycle ) ;
29
+ locales . forEach ( function ( locale ) {
30
+ let hcDefault = new Intl . DateTimeFormat ( locale , { hour : "numeric" } ) . resolvedOptions ( ) . hourCycle ;
31
+ if ( hcDefault === "h11" || hcDefault === "h12" ) {
32
+ assert . sameValue ( hcDefault , new Intl . DateTimeFormat ( locale , { hour : "numeric" , hour12 : true } ) . resolvedOptions ( ) . hourCycle ) ;
33
+
34
+ // no locale has "h24" as a default. see https://github.com/tc39/ecma402/pull/758#issue-1622377292
35
+ assert . sameValue ( "h23" , new Intl . DateTimeFormat ( locale , { hour : "numeric" , hour12 : false } ) . resolvedOptions ( ) . hourCycle ) ;
36
+ }
37
+ if ( hcDefault === "h23" || hcDefault === "h24" ) {
38
+ assert . sameValue ( hcDefault , new Intl . DateTimeFormat ( locale , { hour : "numeric" , hour12 : false } ) . resolvedOptions ( ) . hourCycle ) ;
39
+
40
+ let hcHour12 = new Intl . DateTimeFormat ( locale , { hour : "numeric" , hour12 : true } ) . resolvedOptions ( ) . hourCycle ;
41
+ assert ( ( hcHour12 === "h11" || hcHour12 === "h12" ) , "Expected `hourCycle` to be in ['h11', 'h12']" ) ;
55
42
}
56
43
} ) ;
0 commit comments