commit cd22a94e74ace36a0811771a6497773d8ad1b0b2
parent 61441119ead30a1925b0b091970163a4ca87ea8d
Author: André Bargull <andre.bargull@gmail.com>
Date: Tue, 25 Nov 2025 15:19:36 +0000
Bug 2000225 - Part 6: Handle new UDateFormatSymbolType enum values. r=platform-i18n-reviewers,jfkthame
Both enum value are still in preview state, so they are only defined when
`U_HIDE_DRAFT_API` is not defined.
Differential Revision: https://phabricator.services.mozilla.com/D273815
Diffstat:
2 files changed, 27 insertions(+), 1 deletion(-)
diff --git a/intl/components/src/DisplayNames.cpp b/intl/components/src/DisplayNames.cpp
@@ -89,6 +89,10 @@ static bool IsStandaloneMonth(UDateFormatSymbolType symbolType) {
case UDAT_WEEKDAYS:
case UDAT_SHORT_WEEKDAYS:
case UDAT_AM_PMS:
+# ifndef U_HIDE_DRAFT_API
+ case UDAT_AM_PMS_NARROW:
+ case UDAT_AM_PMS_WIDE:
+# endif
case UDAT_LOCALIZED_CHARS:
case UDAT_ERA_NAMES:
case UDAT_NARROW_MONTHS:
diff --git a/intl/components/src/DisplayNames.h b/intl/components/src/DisplayNames.h
@@ -847,7 +847,29 @@ class DisplayNames final {
Result<Ok, DisplayNamesError> GetDayPeriod(
B& aBuffer, DayPeriod aDayPeriod, Span<const char> aCalendar,
Fallback aFallback = Fallback::None) {
- UDateFormatSymbolType symbolType = UDAT_AM_PMS;
+ UDateFormatSymbolType symbolType;
+ switch (mOptions.style) {
+ case DisplayNames::Style::Long:
+#ifndef U_HIDE_DRAFT_API
+ symbolType = UDAT_AM_PMS_WIDE;
+#else
+ symbolType = UDAT_AM_PMS;
+#endif
+ break;
+
+ case DisplayNames::Style::Abbreviated:
+ case DisplayNames::Style::Short:
+ symbolType = UDAT_AM_PMS;
+ break;
+
+ case DisplayNames::Style::Narrow:
+#ifndef U_HIDE_DRAFT_API
+ symbolType = UDAT_AM_PMS_NARROW;
+#else
+ symbolType = UDAT_AM_PMS;
+#endif
+ break;
+ }
static constexpr int32_t indices[] = {UCAL_AM, UCAL_PM};