v8/test/intl/date-format/related-year.js
Frank Tang aad8c7f81b [Intl] Implement ECMA402 PR 349 and 351
It is controlled by flag harmony_intl_other_calendars.
But this is also pretty intern-dependent with
harmony_intl_add_calendar_numbering_system and should be launched
all together to be meaningful.

https://github.com/tc39/ecma402/pull/349/
#349 Normative: Allow calendar to determine choice of pattern

https://github.com/tc39/ecma402/pull/351
#351 Normative: Permit relatedYear and yearName in output



Bug: v8:9155
Change-Id: I67cd6bba6276bbb995186a9fe6202429d724ba61
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1588401
Reviewed-by: Jakob Kummerow <jkummerow@chromium.org>
Commit-Queue: Frank Tang <ftang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#63972}
2019-09-25 19:53:48 +00:00

15 lines
599 B
JavaScript

// Copyright 2019 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --harmony-intl-other-calendars
// Test it will output relatedYear and yearName
let df = new Intl.DateTimeFormat("zh-u-ca-chinese", {year: "numeric"})
let date = new Date(2019, 5, 1);
assertEquals("2019己亥年", df.format(date));
assertEquals([{type: "relatedYear", value: "2019"},
{type: "yearName", value: "己亥"},
{type: "literal", value: "年"}],
df.formatToParts(date));