Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(275)

Side by Side Diff: test/intl/date-format/date-format-to-parts.js

Issue 2585903002: Ship Intl.DateTimeFormat.formatToParts() (Closed)
Patch Set: test/intl/OWNERS update Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« test/intl/OWNERS ('K') | « test/intl/OWNERS ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Flags: --datetime-format-to-parts
6
Dan Ehrenberg 2016/12/16 23:40:08 Could you leave the Flags: line in until the later
jungshik at Google 2016/12/19 07:27:43 Done.
7 var d = new Date(2016, 11, 15, 14, 10, 34); 5 var d = new Date(2016, 11, 15, 14, 10, 34);
8 var df = Intl.DateTimeFormat("ja", 6 var df = Intl.DateTimeFormat("ja",
9 {hour: 'numeric', minute: 'numeric', second: 'numeric', year: 'numeric', 7 {hour: 'numeric', minute: 'numeric', second: 'numeric', year: 'numeric',
10 month: 'numeric', day: 'numeric', timeZoneName: 'short', era: 'short'}); 8 month: 'numeric', day: 'numeric', timeZoneName: 'short', era: 'short'});
11 9
12 var formattedParts = df.formatToParts(d); 10 var formattedParts = df.formatToParts(d);
13 11
14 var formattedReconstructedFromParts = formattedParts.map((part) => part.value) 12 var formattedReconstructedFromParts = formattedParts.map((part) => part.value)
15 .reduce((accumulated, part) => accumulated + part); 13 .reduce((accumulated, part) => accumulated + part);
16 assertEquals(df.format(d), formattedReconstructedFromParts); 14 assertEquals(df.format(d), formattedReconstructedFromParts);
17 // 西暦2016年11月15日 14:10:34 GMT-7 15 // 西暦2016年11月15日 14:10:34 GMT-7
18 assertEquals(["era", "year", "literal", "month", "literal", "day", "literal", 16 assertEquals(["era", "year", "literal", "month", "literal", "day", "literal",
19 "hour", "literal", "minute", "literal", "second", "literal", 17 "hour", "literal", "minute", "literal", "second", "literal",
20 "timeZoneName"], formattedParts.map((part) => part.type)); 18 "timeZoneName"], formattedParts.map((part) => part.type));
OLDNEW
« test/intl/OWNERS ('K') | « test/intl/OWNERS ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698