OLD | NEW |
(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)); |
OLD | NEW |