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

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

Issue 2273953003: Add support for DateTimeFormat.formatToParts (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: rebased Created 4 years, 3 months 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 // Flags: --datetime-format-to-parts
6
7 var d = new Date(2016, 11, 15, 14, 10, 34);
8 var df = Intl.DateTimeFormat("ja",
9 {hour: 'numeric', minute: 'numeric', second: 'numeric', year: 'numeric',
10 month: 'numeric', day: 'numeric', timeZoneName: 'short', era: 'short'});
11
12 var formattedParts = df.formatToParts(d);
13
14 var formattedReconstructedFromParts = formattedParts.map((part) => part.value)
15 .reduce((accumulated, part) => accumulated + part);
16 assertEquals(df.format(d), formattedReconstructedFromParts);
17 // 西暦2016年11月15日 14:10:34 GMT-7
18 assertEquals(["era", "year", "literal", "month", "literal", "day", "literal",
19 "hour", "literal", "minute", "literal", "second", "literal",
20 "timeZoneName"], formattedParts.map((part) => part.type));
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698