1
0
mirror of https://git.savannah.gnu.org/git/guix.git synced 2026-04-06 21:20:33 +02:00
Files
guix/gnu/packages/patches/icu4c-bug-1954138-dtitvfmt-adopt-calendar.patch
Ian Eure fee676c728 gnu: Add icu4c-78.
* gnu/packages/icu4c.scm (icu4c-78): New variable.
* gnu/local.mk (dist_patch_DATA): Add icu4c patches.
* gnu/packages/patches/icu4c-78-double-conversion.patch: New file.
* gnu/packages/patches/icu4c-bug-1706949-wasi-workaround.patch: New file.
* gnu/packages/patches/icu4c-bug-1790071-ICU-22132-standardize-vtzone-output.patch: New file.
* gnu/packages/patches/icu4c-bug-1856290-ICU-20548-dateinterval-timezone.patch: New file.
* gnu/packages/patches/icu4c-bug-1954138-dtitvfmt-adopt-calendar.patch: New file.
* gnu/packages/patches/icu4c-bug-1972781-chinese-based-calendar.patch: New file.
* gnu/packages/patches/icu4c-bug-2000225-ICU-23264-increase-measure-unit-capacity.patch: New file.
* gnu/packages/patches/icu4c-bug-2002735-ICU-23277-coptic-single-era.patch: New file.
* gnu/packages/patches/icu4c-suppress-warnings.patch: New file.
2026-01-20 18:04:58 -08:00

70 lines
2.6 KiB
Diff

diff --git a/source/i18n/dtitvfmt.cpp b/source/i18n/dtitvfmt.cpp
--- a/source/i18n/dtitvfmt.cpp
+++ b/source/i18n/dtitvfmt.cpp
@@ -630,16 +630,38 @@ DateIntervalFormat::getTimeZone() const
{
if (fDateFormat != nullptr) {
Mutex lock(&gFormatterMutex);
return fDateFormat->getTimeZone();
}
// If fDateFormat is nullptr (unexpected), create default timezone.
return *(TimeZone::createDefault());
}
+
+void DateIntervalFormat::adoptCalendar(Calendar *calendarToAdopt) {
+ if (fDateFormat != nullptr) {
+ fDateFormat->adoptCalendar(calendarToAdopt);
+ }
+
+ // The fDateFormat has the primary calendar for the DateIntervalFormat and has
+ // ownership of any adopted Calendar; fFromCalendar and fToCalendar are internal
+ // work clones of that calendar.
+
+ delete fFromCalendar;
+ fFromCalendar = nullptr;
+
+ delete fToCalendar;
+ fToCalendar = nullptr;
+
+ const Calendar *calendar = fDateFormat->getCalendar();
+ if (calendar != nullptr) {
+ fFromCalendar = calendar->clone();
+ fToCalendar = calendar->clone();
+ }
+}
void
DateIntervalFormat::setContext(UDisplayContext value, UErrorCode& status)
{
if (U_FAILURE(status))
return;
if (static_cast<UDisplayContextType>(static_cast<uint32_t>(value) >> 8) == UDISPCTX_TYPE_CAPITALIZATION) {
fCapitalizationContext = value;
diff --git a/source/i18n/unicode/dtitvfmt.h b/source/i18n/unicode/dtitvfmt.h
--- a/source/i18n/unicode/dtitvfmt.h
+++ b/source/i18n/unicode/dtitvfmt.h
@@ -625,16 +625,23 @@ public:
/**
* Sets the time zone for the calendar used by this DateIntervalFormat object.
* @param zone the new time zone.
* @stable ICU 4.8
*/
U_I18N_API virtual void setTimeZone(const TimeZone& zone);
/**
+ * Sets the calendar used by this DateIntervalFormat object. The caller no longer owns
+ * the Calendar object and should not delete it after this call.
+ * @param calendarToAdopt the Calendar to be adopted.
+ */
+ U_I18N_API virtual void adoptCalendar(Calendar *calendarToAdopt);
+
+ /**
* Set a particular UDisplayContext value in the formatter, such as
* UDISPCTX_CAPITALIZATION_FOR_STANDALONE. This causes the formatted
* result to be capitalized appropriately for the context in which
* it is intended to be used, considering both the locale and the
* type of field at the beginning of the formatted result.
* @param value The UDisplayContext value to set.
* @param status Input/output status. If at entry this indicates a failure
* status, the function will do nothing; otherwise this will be