@@ -10,8 +10,8 @@ function assert(value, expected, message) {
10
10
}
11
11
}
12
12
13
- function newDateUTC ( ) {
14
- var date = new Date ( ... arguments )
13
+ function newDateUTC ( str ) {
14
+ var date = new Date ( str ) ;
15
15
var localTime = date . getTime ( ) ;
16
16
var localOffset = date . getTimezoneOffset ( ) * 60000 ;
17
17
var utc = localTime + localOffset ;
@@ -26,7 +26,7 @@ assert(new IntlPolyfill.NumberFormat('de-DE', {
26
26
assert ( new IntlPolyfill . NumberFormat ( 'en-US' , {
27
27
style : 'currency' ,
28
28
currency : 'GBP' ,
29
- minimumFractionDigits : 2 ,
29
+ minimumFractionDigits : 2
30
30
} ) . format ( 59.88 ) , '£59.88' , 'currency with fragtional digits' ) ;
31
31
32
32
assert ( new IntlPolyfill . DateTimeFormat ( 'en' , {
@@ -51,12 +51,7 @@ assert(new IntlPolyfill.DateTimeFormat('en-GB', {
51
51
assert ( new IntlPolyfill . DateTimeFormat ( 'en' , {
52
52
month :'long' ,
53
53
year : 'numeric'
54
- } ) . format ( new Date ( '2016/01/16' ) ) , 'January 2016' , 'month should be long' ) ;
55
-
56
- // Issues #190, #192
57
- assert ( new IntlPolyfill . DateTimeFormat ( 'en-us' , {
58
- month :'long' ,
59
- } ) . format ( new Date ( 2016 , 0 , 1 ) ) , 'January' , 'month should be long' ) ;
54
+ } ) . format ( new Date ( '2016/01/16' ) ) , 'January 2016' , 'month and year should be long' ) ;
60
55
61
56
// issue #196
62
57
/ a * $ / . exec ( 'b' + new Array ( 32768 + 1 ) . join ( 'a' ) ) ;
@@ -68,3 +63,38 @@ assert(RegExp.leftContext, leftContext, 'RegExp.leftContext restored');
68
63
assert ( RegExp . input , input , 'RegExp.input restored' ) ;
69
64
assert ( RegExp . lastMatch , lastMatch , 'RegExp.lastMatch restored' ) ;
70
65
'a' . match ( / a / ) ;
66
+
67
+ // Issues #190, #192
68
+ assert ( new IntlPolyfill . DateTimeFormat ( 'en-us' , {
69
+ month : 'long'
70
+ } ) . format ( new Date ( 2016 , 0 , 1 ) ) , 'January' , 'single month should be long' ) ;
71
+
72
+ assert ( new IntlPolyfill . DateTimeFormat ( 'en-us' , {
73
+ day : '2-digit'
74
+ } ) . format ( new Date ( 2016 , 0 , 1 ) ) , '01' , 'single day should be 2-digit' ) ;
75
+
76
+ assert ( new IntlPolyfill . DateTimeFormat ( 'en-us' , {
77
+ year : '2-digit'
78
+ } ) . format ( new Date ( 2016 , 0 , 1 ) ) , '16' , 'single year should be 2-digit' ) ;
79
+
80
+ assert ( new IntlPolyfill . DateTimeFormat ( 'en-us' , {
81
+ weekday : 'short'
82
+ } ) . format ( new Date ( 2016 , 0 , 1 ) ) , 'Fri' , 'single weekday should be short' ) ;
83
+
84
+ assert ( new IntlPolyfill . DateTimeFormat ( 'en-us' , {
85
+ minute : '2-digit'
86
+ } ) . format ( new Date ( 2016 , 0 , 1 ) ) , '00' , 'single minute should be 2-digit' ) ;
87
+
88
+ assert ( new IntlPolyfill . DateTimeFormat ( 'en-us' , {
89
+ second : '2-digit'
90
+ } ) . format ( new Date ( 2016 , 0 , 1 ) ) , '00' , 'single second should be 2-digit' ) ;
91
+
92
+ // alternative, hour can't alway produce a single digit, because of ampm, but
93
+ // this case should be cover by CLDR availableFormats
94
+ assert ( new IntlPolyfill . DateTimeFormat ( 'en-us' , {
95
+ hour : 'numeric'
96
+ } ) . format ( new Date ( 2016 , 0 , 1 , 6 ) ) , '6 AM' , 'single second should be 2-digit' ) ;
97
+
98
+ assert ( new IntlPolyfill . DateTimeFormat ( 'en-GB' , {
99
+ hour : 'numeric'
100
+ } ) . format ( new Date ( 2016 , 0 , 1 , 6 ) ) , '6' , 'single second should be 2-digit' ) ;
0 commit comments