From patchwork Fri Mar 15 11:49:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rafal Luzynski X-Patchwork-Id: 31862 Received: (qmail 92437 invoked by alias); 15 Mar 2019 11:49:36 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 92426 invoked by uid 89); 15 Mar 2019 11:49:36 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-17.4 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy= X-HELO: shared-ano163.rev.nazwa.pl X-Spam-Score: -1 Date: Fri, 15 Mar 2019 12:49:27 +0100 (CET) From: Rafal Luzynski To: libc-alpha@sourceware.org Cc: TAMUKI Shoichi , Felix Yan Message-ID: <1517391513.248381.1552650568043@poczta.nazwa.pl> In-Reply-To: <988338284.248045.1552650382964@poczta.nazwa.pl> References: <988338284.248045.1552650382964@poczta.nazwa.pl> Subject: [PATCH 3/3] time: Add tests for Minguo calendar [BZ #24293] MIME-Version: 1.0 [BZ #24293] * time/Makefile (LOCALES): Add cmn_TW.UTF-8 and zh_TW.UTF-8. * time/tst-strftime2.c (locales): Likewise. (dates): Add 1910-04-01, 1911-12-31, 1912-07-29, 1912-07-30, and 1913-04-01. (mkreftable): Add rules for the new locales and the new dates. --- time/Makefile | 2 +- time/tst-strftime2.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 47 insertions(+), 5 deletions(-) static const char *formats[] = { "%EY", "%_EY", "%-EY" }; @@ -37,6 +38,11 @@ typedef struct static const date_t dates[] = { + { 1, 4, 1910 }, + { 31, 12, 1911 }, + { 29, 7, 1912 }, + { 30, 7, 1912 }, + { 1, 4, 1913 }, { 1, 4, 1988 }, { 7, 1, 1989 }, { 8, 1, 1989 }, @@ -68,8 +74,10 @@ mkreftable (void) { int i, j, k; const char *era; - static const int yrj[] = { 63, 64, 1, 2, 9, 10 }; - static const int yrb[] = { 2531, 2532, 2532, 2533, 2540, 2541 }; + static const int yrj[] = { 43, 44, 45, 1, 2, 63, 64, 1, 2, 9, 10 }; + static const int yrb[] = { 2453, 2454, 2455, 2455, 2456, + 2531, 2532, 2532, 2533, 2540, 2541 }; + static const int yrc[] = { 2, 1, 1, 1, 2, 77, 78, 78, 79, 86, 87 }; for (i = 0; i < array_length (locales); i++) for (j = 0; j < array_length (formats); j++) @@ -77,7 +85,11 @@ mkreftable (void) { if (i == 0) /* ja_JP */ { - if (is_before (&dates[k], 8, 1, 1989)) + if (is_before (&dates[k], 30, 7, 1912)) + era = "\xe6\x98\x8e\xe6\xb2\xbb"; + else if (is_before (&dates[k], 25, 12, 1926)) + era = "\xe5\xa4\xa7\xe6\xad\xa3"; + else if (is_before (&dates[k], 8, 1, 1989)) era = "\xe6\x98\xad\xe5\x92\x8c"; else era = "\xe5\xb9\xb3\xe6\x88\x90"; @@ -104,6 +116,36 @@ mkreftable (void) era = "\xe0\xb8\x9e\x2e\xe0\xb8\xa8\x2e "; sprintf (ref[i][j][k], "%s%d", era, yrb[k]); } + else if (i == 3) /* cmn_TW */ + { + if (is_before (&dates[k], 1, 1, 1912)) + era = "\xe6\xb0\x91\xe5\x89\x8d"; + else + era = "\xe6\xb0\x91\xe5\x9c\x8b"; + if (dates[k].y == 1912) + sprintf (ref[i][j][k], "%s\xe5\x85\x83\xe5\xb9\xb4", era); + else if (j == 0) + sprintf (ref[i][j][k], "%s%02d\xe5\xb9\xb4", era, yrc[k]); + else if (j == 1) + sprintf (ref[i][j][k], "%s%2d\xe5\xb9\xb4", era, yrc[k]); + else + sprintf (ref[i][j][k], "%s%d\xe5\xb9\xb4", era, yrc[k]); + } + else if (i == 4) /* zh_TW */ + { + if (is_before (&dates[k], 1, 1, 1912)) + era = "\xe6\xb0\x91\xe5\x89\x8d"; + else + era = "\xe6\xb0\x91\xe5\x9c\x8b"; + if (dates[k].y == 1912) + sprintf (ref[i][j][k], "%s\xe5\x85\x83\xe5\xb9\xb4", era); + else if (j == 0) + sprintf (ref[i][j][k], "%s%02d\xe5\xb9\xb4", era, yrc[k]); + else if (j == 1) + sprintf (ref[i][j][k], "%s%2d\xe5\xb9\xb4", era, yrc[k]); + else + sprintf (ref[i][j][k], "%s%d\xe5\xb9\xb4", era, yrc[k]); + } else { assert (0); /* Unreachable. */ diff --git a/time/Makefile b/time/Makefile index 5c6304e..9f70800 100644 --- a/time/Makefile +++ b/time/Makefile @@ -50,7 +50,7 @@ include ../Rules ifeq ($(run-built-tests),yes) LOCALES := de_DE.ISO-8859-1 en_US.ISO-8859-1 ja_JP.EUC-JP fr_FR.UTF-8 \ es_ES.UTF-8 pl_PL.UTF-8 ru_RU.UTF-8 \ - ja_JP.UTF-8 lo_LA.UTF-8 th_TH.UTF-8 + ja_JP.UTF-8 lo_LA.UTF-8 th_TH.UTF-8 cmn_TW.UTF-8 zh_TW.UTF-8 include ../gen-locales.mk $(objpfx)tst-ftime_l.out: $(gen-locales) diff --git a/time/tst-strftime2.c b/time/tst-strftime2.c index bf5a66d..fb7f6cd 100644 --- a/time/tst-strftime2.c +++ b/time/tst-strftime2.c @@ -26,7 +26,8 @@ #include #include -static const char *locales[] = { "ja_JP.UTF-8", "lo_LA.UTF-8", "th_TH.UTF-8" }; +static const char *locales[] = { "ja_JP.UTF-8", "lo_LA.UTF-8", "th_TH.UTF-8", + "cmn_TW.UTF-8", "zh_TW.UTF-8" };