1 // Copyright 2019 Google Inc. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
5 esid: sec-createdatetimeformat
6 description: Checks basic handling of fractionalSecondDigits.
7 features: [Intl.DateTimeFormat-fractionalSecondDigits]
11 const d1 = new Date(2019, 7, 10, 1, 2, 3, 234);
12 const d2 = new Date(2019, 7, 10, 1, 2, 3, 567);
14 let dtf = new Intl.DateTimeFormat(
15 'en', { minute: "numeric", second: "numeric", fractionalSecondDigits: undefined});
16 assert.sameValue(dtf.format(d1), "02:03", "no fractionalSecondDigits");
17 assert.sameValue(dtf.format(d2), "02:03", "no fractionalSecondDigits");
19 dtf = new Intl.DateTimeFormat(
20 'en', { minute: "numeric", second: "numeric", fractionalSecondDigits: 1});
21 assert.sameValue(dtf.format(d1), "02:03.2", "1 fractionalSecondDigits round down");
22 assert.sameValue(dtf.format(d2), "02:03.5", "1 fractionalSecondDigits round down");
24 dtf = new Intl.DateTimeFormat(
25 'en', { minute: "numeric", second: "numeric", fractionalSecondDigits: 2});
26 assert.sameValue(dtf.format(d1), "02:03.23", "2 fractionalSecondDigits round down");
27 assert.sameValue(dtf.format(d2), "02:03.56", "2 fractionalSecondDigits round down");
29 dtf = new Intl.DateTimeFormat(
30 'en', { minute: "numeric", second: "numeric", fractionalSecondDigits: 3});
31 assert.sameValue(dtf.format(d1), "02:03.234", "3 fractionalSecondDigits round down");
32 assert.sameValue(dtf.format(d2), "02:03.567", "3 fractionalSecondDigits round down");