UNPKG

3.15 kBJavaScriptView Raw
1var IntlPolyfill = require('./');
2
3console.log(new Intl.NumberFormat().format());
4console.log(new IntlPolyfill.NumberFormat('en', {}).format());
5
6console.log(new IntlPolyfill.DateTimeFormat('en-GB', {
7 hour: '2-digit',
8 hour12: false,
9 minute: 'numeric'
10}).resolvedOptions());
11console.log(new IntlPolyfill.DateTimeFormat('en-GB', {
12 hour: '2-digit',
13 hour12: false,
14 minute: 'numeric'
15}).format(new Date(1983, 9, 13)));
16
17var d = new Date('2015/04/05');
18var o = { hour: '2-digit', minute: '2-digit', timeZoneName: 'short' };
19var a = new Intl.DateTimeFormat('en-US', o).format(d);
20var b = new IntlPolyfill.DateTimeFormat('en-US', o).format(d);
21console.log('chrome : ', a);
22console.log('polyfill: ', b);
23
24var d = new Date('2015/04/05');
25var o = { year: '2-digit', month: '2-digit', day: '2-digit' };
26var a = new Intl.DateTimeFormat('en', o).format(d);
27var b = new IntlPolyfill.DateTimeFormat('en', o).format(d);
28console.log('chrome : ', a);
29console.log('polyfill: ', b);
30
31// issue #139
32var o = { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' };
33var a = new Intl.DateTimeFormat('ja-JP', o).format(d);
34var b = new IntlPolyfill.DateTimeFormat('ja-JP', o).format(d);
35console.log('chrome : ', a);
36console.log('polyfill: ', b);
37
38// issue #128
39var a = new Intl.DateTimeFormat('en', {
40 month: '2-digit'
41}).format(d);
42var b = new IntlPolyfill.DateTimeFormat('en', {
43 month: '2-digit'
44}).format(d);
45console.log('chrome : ', a);
46console.log('polyfill: ', b);
47
48// issue 125
49var o = {
50 weekday: 'long'
51};
52var a = new Intl.DateTimeFormat('en-US', o).format(d);
53var b = new IntlPolyfill.DateTimeFormat('en-US', o).format(d);
54console.log('chrome : ', a);
55console.log('polyfill: ', b);
56
57// issue 117
58var o = {
59 month: 'long'
60};
61var a = new Intl.DateTimeFormat('en', o).format(d);
62var b = new IntlPolyfill.DateTimeFormat('en', o).format(d);
63console.log('chrome : ', a);
64console.log('polyfill: ', b);
65
66var o = {
67 month: 'long',
68 day: 'numeric'
69};
70var a = new Intl.DateTimeFormat('en', o).format(d);
71var b = new IntlPolyfill.DateTimeFormat('en', o).format(d);
72console.log('chrome : ', a);
73console.log('polyfill: ', b);
74console.log('ddddd');
75// issue 69
76var d1 = new Date(Date.UTC(2012, 11, 20, 3, 0, 0));
77var o = { year: "numeric", month: "short", day: "numeric", weekday: "short" };
78// var a = new Intl.DateTimeFormat('zh', o).format(d1);
79var uu = new IntlPolyfill.DateTimeFormat('zh', o);
80var b = uu.format(d1);
81console.log('expected: 2012年12月19日星期三');
82//console.log('chrome : ', a);
83console.log('polyfill: ', b); /// tbd
84
85// console.log(new IntlPolyfill.DateTimeFormat("ja", {year: "numeric", month: "long", day: "numeric", weekday: "long"}).format(new Date()));
86
87console.log('\nIssue #126:');
88var o = { month: 'long' };
89var a = new Intl.DateTimeFormat('ru', o).format(d);
90var b = new IntlPolyfill.DateTimeFormat('ru', o).format(d);
91console.log('chrome : ', a);
92console.log('polyfill: ', b);
93var o = { month: 'long', day: 'numeric' };
94var a = new Intl.DateTimeFormat('ru', o).format(d);
95var b = new IntlPolyfill.DateTimeFormat('ru', o).format(d);
96console.log('chrome : ', a);
97console.log('polyfill: ', b);