Skip to content

Commit b615443

Browse files
FrankYFTangV8 LUCI CQ
authored andcommitted
[intl] Fix {minute: '2-digit'}
Set the correct ICU option flag to respect all field length for pattern matching. Fixed: 40855035 Change-Id: I4b89301e4ad98e3db97708a309d11823da8c026f Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/5646178 Reviewed-by: Shu-yu Guo <[email protected]> Commit-Queue: Frank Tang <[email protected]> Cr-Commit-Position: refs/heads/main@{#94613}
1 parent 96c0152 commit b615443

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1847,7 +1847,7 @@ std::unique_ptr<icu::SimpleDateFormat> CreateICUDateFormat(
18471847
// has to be discussed. Revisit once the spec is clarified/revised.
18481848
icu::UnicodeString pattern;
18491849
UErrorCode status = U_ZERO_ERROR;
1850-
pattern = generator->getBestPattern(skeleton, UDATPG_MATCH_HOUR_FIELD_LENGTH,
1850+
pattern = generator->getBestPattern(skeleton, UDATPG_MATCH_ALL_FIELDS_LENGTH,
18511851
status);
18521852
pattern = ReplaceHourCycleInPattern(pattern, hc);
18531853
DCHECK(U_SUCCESS(status));

test/intl/regress-40855035.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// Copyright 2024 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+
const formatter = new Intl.DateTimeFormat('en-us',{minute: '2-digit'})
6+
assertEquals("02", formatter.format(new Date(2024, 6, 21, 3, 2, 0)));

0 commit comments

Comments
 (0)