From 983578c10e37a2d51505e46fbcadfd8346585d29 Mon Sep 17 00:00:00 2001 From: Andrey Bondrov Date: Mon, 20 May 2019 15:52:05 +1000 Subject: [PATCH] Backport upstream patch to make RelativeDateTimeFormatter handle offset of -0 --- icu-57.1-ICU-12936.patch | 122 +++++++++++++++++++++++++++++++++++++++ icu.spec | 4 +- 2 files changed, 125 insertions(+), 1 deletion(-) create mode 100644 icu-57.1-ICU-12936.patch diff --git a/icu-57.1-ICU-12936.patch b/icu-57.1-ICU-12936.patch new file mode 100644 index 0000000..efd84ce --- /dev/null +++ b/icu-57.1-ICU-12936.patch @@ -0,0 +1,122 @@ +diff -urN icu/source/i18n/reldatefmt.cpp icu-patched/source/i18n/reldatefmt.cpp +--- icu/source/i18n/reldatefmt.cpp 2016-03-24 06:49:42.000000000 +1000 ++++ icu-patched/source/i18n/reldatefmt.cpp 2019-05-20 15:49:17.206641871 +1000 +@@ -12,6 +12,7 @@ + + #if !UCONFIG_NO_FORMATTING && !UCONFIG_NO_BREAK_ITERATION + ++#include + #include "unicode/dtfmtsym.h" + #include "unicode/ureldatefmt.h" + #include "unicode/udisplaycontext.h" +@@ -909,7 +910,7 @@ + return appendTo; + } + UDateDirection direction = UDAT_DIRECTION_NEXT; +- if (offset < 0) { ++ if (std::signbit(offset)) { // needed to handle -0.0 + direction = UDAT_DIRECTION_LAST; + offset = -offset; + } +diff -urN icu/source/test/cintltst/crelativedateformattest.c icu-patched/source/test/cintltst/crelativedateformattest.c +--- icu/source/test/cintltst/crelativedateformattest.c 2016-03-24 06:48:22.000000000 +1000 ++++ icu-patched/source/test/cintltst/crelativedateformattest.c 2019-05-20 15:49:17.207641871 +1000 +@@ -28,9 +28,24 @@ + TESTCASE(TestCombineDateTime); + } + +-static const double offsets[] = { -5.0, -2.2, -2.0, -1.0, -0.7, 0.0, 0.7, 1.0, 2.0, 5.0 }; ++static const double offsets[] = { -5.0, -2.2, -2.0, -1.0, -0.7, -0.0, 0.0, 0.7, 1.0, 2.0, 5.0 }; + enum { kNumOffsets = UPRV_LENGTHOF(offsets) }; + ++static const char* en_decDef_long_midSent_sec[kNumOffsets*2] = { ++/* text numeric */ ++ "5 seconds ago", "5 seconds ago", /* -5 */ ++ "2.2 seconds ago", "2.2 seconds ago", /* -2.2 */ ++ "2 seconds ago", "2 seconds ago", /* -2 */ ++ "1 second ago", "1 second ago", /* -1 */ ++ "0.7 seconds ago", "0.7 seconds ago", /* -0.7 */ ++ "now", "0 seconds ago", /* -0 */ ++ "now", "in 0 seconds", /* 0 */ ++ "in 0.7 seconds", "in 0.7 seconds", /* 0.7 */ ++ "in 1 second", "in 1 second", /* 1 */ ++ "in 2 seconds", "in 2 seconds", /* 2 */ ++ "in 5 seconds", "in 5 seconds" /* 5 */ ++}; ++ + static const char* en_decDef_long_midSent_week[kNumOffsets*2] = { + /* text numeric */ + "5 weeks ago", "5 weeks ago", /* -5 */ +@@ -38,6 +53,7 @@ + "2 weeks ago", "2 weeks ago", /* -2 */ + "last week", "1 week ago", /* -1 */ + "0.7 weeks ago", "0.7 weeks ago", /* -0.7 */ ++ "this week", "0 weeks ago", /* -0 */ + "this week", "in 0 weeks", /* 0 */ + "in 0.7 weeks", "in 0.7 weeks", /* 0.7 */ + "next week", "in 1 week", /* 1 */ +@@ -52,6 +68,7 @@ + "2 weeks ago", "2 weeks ago", /* -2 */ + "last week", "1 week ago", /* -1 */ + "0 weeks ago", "0 weeks ago", /* -0.7 */ ++ "this week", "0 weeks ago", /* -0 */ + "this week", "in 0 weeks", /* 0 */ + "in 0 weeks", "in 0 weeks", /* 0.7 */ + "next week", "in 1 week", /* 1 */ +@@ -66,6 +83,7 @@ + "2 wk. ago", "2 wk. ago", /* -2 */ + "last wk.", "1 wk. ago", /* -1 */ + "0.7 wk. ago", "0.7 wk. ago", /* -0.7 */ ++ "this wk.", "0 wk. ago", /* -0 */ + "this wk.", "in 0 wk.", /* 0 */ + "in 0.7 wk.", "in 0.7 wk.", /* 0.7 */ + "next wk.", "in 1 wk.", /* 1 */ +@@ -80,6 +98,7 @@ + "2 minutes ago", "2 minutes ago", /* -2 */ + "1 minute ago", "1 minute ago", /* -1 */ + "0.7 minutes ago", "0.7 minutes ago", /* -0.7 */ ++ "0 minutes ago", "0 minutes ago", /* -0 */ + "in 0 minutes", "in 0 minutes", /* 0 */ + "in 0.7 minutes", "in 0.7 minutes", /* 0.7 */ + "in 1 minute", "in 1 minute", /* 1 */ +@@ -89,16 +108,17 @@ + + static const char* en_dec0_long_midSent_tues[kNumOffsets*2] = { + /* text numeric */ +- ""/*no data */, ""/*no data */, /* -5 */ ++ "5 Tuesdays ago", "5 Tuesdays ago", /* -5 */ + ""/*no data */, ""/*no data */, /* -2.2 */ +- ""/*no data */, ""/*no data */, /* -2 */ +- "last Tuesday", ""/*no data */, /* -1 */ ++ "2 Tuesdays ago", "2 Tuesdays ago", /* -2 */ ++ "last Tuesday", "1 Tuesday ago", /* -1 */ + ""/*no data */, ""/*no data */, /* -0.7 */ +- "this Tuesday", ""/*no data */, /* 0 */ ++ "this Tuesday", "0 Tuesdays ago", /* -0 */ ++ "this Tuesday", "in 0 Tuesdays", /* 0 */ + ""/*no data */, ""/*no data */, /* 0.7 */ +- "next Tuesday", ""/*no data */, /* 1 */ +- ""/*no data */, ""/*no data */, /* 2 */ +- ""/*no data */, ""/*no data */, /* 5 */ ++ "next Tuesday", "in 1 Tuesday", /* 1 */ ++ "in 2 Tuesdays", "in 2 Tuesdays", /* 2 */ ++ "in 5 Tuesdays", "in 5 Tuesdays", /* 5 */ + }; + + static const char* fr_decDef_long_midSent_day[kNumOffsets*2] = { +@@ -108,6 +128,7 @@ + "avant-hier", "il y a 2 jours", /* -2 */ + "hier", "il y a 1 jour", /* -1 */ + "il y a 0,7 jour", "il y a 0,7 jour", /* -0.7 */ ++ "aujourd\\u2019hui", "il y a 0 jour", /* -0 */ + "aujourd\\u2019hui", "dans 0 jour", /* 0 */ + "dans 0,7 jour", "dans 0,7 jour", /* 0.7 */ + "demain", "dans 1 jour", /* 1 */ +@@ -126,6 +147,7 @@ + } RelDateTimeFormatTestItem; + + static const RelDateTimeFormatTestItem fmtTestItems[] = { ++ { "en", -1, UDAT_STYLE_LONG, UDISPCTX_CAPITALIZATION_FOR_MIDDLE_OF_SENTENCE, UDAT_REL_UNIT_SECOND, en_decDef_long_midSent_sec }, + { "en", -1, UDAT_STYLE_LONG, UDISPCTX_CAPITALIZATION_FOR_MIDDLE_OF_SENTENCE, UDAT_REL_UNIT_WEEK, en_decDef_long_midSent_week }, + { "en", 0, UDAT_STYLE_LONG, UDISPCTX_CAPITALIZATION_FOR_MIDDLE_OF_SENTENCE, UDAT_REL_UNIT_WEEK, en_dec0_long_midSent_week }, + { "en", -1, UDAT_STYLE_SHORT, UDISPCTX_CAPITALIZATION_FOR_MIDDLE_OF_SENTENCE, UDAT_REL_UNIT_WEEK, en_decDef_short_midSent_week }, diff --git a/icu.spec b/icu.spec index 983e900..e276a1c 100644 --- a/icu.spec +++ b/icu.spec @@ -16,13 +16,14 @@ Summary: International Components for Unicode Name: icu Epoch: 1 Version: 57.1 -Release: 6 +Release: 7 License: MIT Group: System/Libraries Url: http://www.icu-project.org/index.html Source0: http://download.icu-project.org/files/icu4c/%{version}/%{name}4c-%{tarballver}-src.tgz Source1: http://download.icu-project.org/files/icu4c/%{version}/%{name}4c-%{tarballver}-docs.zip Patch0: %{name}4c-49.1-setBreakType.patch +Patch1: icu-57.1-ICU-12936.patch # From Fedora package Patch10: icu.7601.Indic-ccmp.patch Patch11: icu.8198.revert.icu5431.patch @@ -207,6 +208,7 @@ Development files and headers for the International Components for Unicode. %prep %setup -qn %{name} %patch0 -p1 -b .setBreakType +%patch1 -p1 %patch10 -p1 %patch11 -p2 -R %patch12 -p1