Skip to content

Commit fb63e5c

Browse files
FrankYFTangCommit Bot
authored andcommitted
[Intl] Fix output of hour:'2-digit', hour12: true
Bug: chromium:527926 Change-Id: I783ba59c6e4b117163e058032fb04283e1f43c46 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1529260 Reviewed-by: Sathya Gunasekaran <[email protected]> Commit-Queue: Frank Tang <[email protected]> Cr-Commit-Position: refs/heads/master@{#60379}
1 parent cdda5de commit fb63e5c

2 files changed

Lines changed: 21 additions & 1 deletion

File tree

src/objects/js-date-time-format.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -896,7 +896,8 @@ std::unique_ptr<icu::SimpleDateFormat> CreateICUDateFormat(
896896
// has to be discussed. Revisit once the spec is clarified/revised.
897897
icu::UnicodeString pattern;
898898
UErrorCode status = U_ZERO_ERROR;
899-
pattern = generator.getBestPattern(skeleton, status);
899+
pattern = generator.getBestPattern(skeleton, UDATPG_MATCH_HOUR_FIELD_LENGTH,
900+
status);
900901
CHECK(U_SUCCESS(status));
901902

902903
// Make formatter from skeleton. Calendar and numbering system are added

test/intl/regress-527926.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Copyright 2019 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+
let date = new Date(2015, 8, 1, 3, 0, 0);
6+
var fmt = new Intl.DateTimeFormat('ru', {hour:'2-digit', minute: '2-digit'})
7+
assertEquals("03:00", fmt.format(date));
8+
9+
fmt = new Intl.DateTimeFormat(
10+
'en', {hour:'2-digit', minute: '2-digit', hour12: false});
11+
assertEquals("03:00", fmt.format(date));
12+
13+
fmt = new Intl.DateTimeFormat(
14+
'ru', {hour:'2-digit', minute: '2-digit', hour12: false});
15+
assertEquals("03:00", fmt.format(date));
16+
17+
fmt = new Intl.DateTimeFormat(
18+
'ru', {hour:'2-digit', minute: '2-digit', hour12: true});
19+
assertEquals("03:00 AM", fmt.format(date));

0 commit comments

Comments
 (0)