This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[PATCH 3/4] time: Add tests for Minguo calendar [BZ #24293]
- From: TAMUKI Shoichi <tamuki at linet dot gr dot jp>
- To: libc-alpha at sourceware dot org
- Date: Mon, 01 Apr 2019 12:59:11 +0900
- Subject: [PATCH 3/4] time: Add tests for Minguo calendar [BZ #24293]
- References: <201904010352.AA04315@tamuki.linet.gr.jp>
The original author: Rafal Luzynski <digitalfreak@lingonborough.com>
ChangeLog:
[BZ #24293]
* time/Makefile (LOCALES): Add zh_TW.UTF-8, cmn_TW.UTF-8,
hak_TW.UTF-8, nan_TW.UTF-8, and lzh_TW.UTF-8.
* time/tst-strftime2.c (locales): Likewise.
(dates): Add 1910-04-01, 1911-12-31, 1912-01-01, 1913-04-01,
2010-04-01, and 2011-04-01.
(mkreftable): Add rules for the new locales and the new dates.
---
time/Makefile | 4 +++-
time/tst-strftime2.c | 37 +++++++++++++++++++++++++++++++------
2 files changed, 34 insertions(+), 7 deletions(-)
diff --git a/time/Makefile b/time/Makefile
index 5c6304ece1..e722a8f631 100644
--- a/time/Makefile
+++ b/time/Makefile
@@ -50,7 +50,9 @@ 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 \
+ zh_TW.UTF-8 cmn_TW.UTF-8 hak_TW.UTF-8 \
+ nan_TW.UTF-8 lzh_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 f537d93ba4..2c94bf592e 100644
--- a/time/tst-strftime2.c
+++ b/time/tst-strftime2.c
@@ -29,7 +29,9 @@
static const char *locales[] =
{
- "ja_JP.UTF-8", "lo_LA.UTF-8", "th_TH.UTF-8"
+ "ja_JP.UTF-8", "lo_LA.UTF-8", "th_TH.UTF-8",
+ "zh_TW.UTF-8", "cmn_TW.UTF-8", "hak_TW.UTF-8",
+ "nan_TW.UTF-8", "lzh_TW.UTF-8"
};
static const char *formats[] = { "%EY", "%_EY", "%-EY" };
@@ -41,12 +43,18 @@ typedef struct
static const date_t dates[] =
{
+ { 1, 4, 1910 },
+ { 31, 12, 1911 },
+ { 1, 1, 1912 },
+ { 1, 4, 1913 },
{ 1, 4, 1988 },
{ 7, 1, 1989 },
{ 8, 1, 1989 },
{ 1, 4, 1990 },
{ 1, 4, 1997 },
- { 1, 4, 1998 }
+ { 1, 4, 1998 },
+ { 1, 4, 2010 },
+ { 1, 4, 2011 }
};
static char ref[array_length (locales)][array_length (formats)]
@@ -75,12 +83,21 @@ mkreftable (void)
/* Japanese era year to be checked. */
static const int yrj[] =
{
- 63, 64, 1, 2, 9, 10
+ 43, 44, 45, 2,
+ 63, 64, 1, 2, 9, 10, 22, 23
};
/* Buddhist calendar year to be checked. */
static const int yrb[] =
{
- 2531, 2532, 2532, 2533, 2540, 2541
+ 2453, 2454, 2455, 2456,
+ 2531, 2532, 2532, 2533, 2540, 2541, 2553, 2554
+ };
+ /* R.O.C. calendar year to be checked. Negative number is prior to
+ Minguo counting up. */
+ static const int yrc[] =
+ {
+ -2, -1, 1, 2,
+ 77, 78, 78, 79, 86, 87, 99, 100
};
for (i = 0; i < array_length (locales); i++)
@@ -89,14 +106,22 @@ mkreftable (void)
{
if (i == 0) /* ja_JP */
{
- era = (is_before (k, 8, 1, 1989)) ? "\u662d\u548c"
- : "\u5e73\u6210";
+ era = (is_before (k, 30, 7, 1912)) ? "\u660e\u6cbb"
+ : (is_before (k, 25, 12, 1926)) ? "\u5927\u6b63"
+ : (is_before (k, 8, 1, 1989)) ? "\u662d\u548c"
+ : "\u5e73\u6210";
yr = yrj[k], sfx = "\u5e74";
}
else if (i == 1) /* lo_LA */
era = "\u0e9e.\u0eaa. ", yr = yrb[k], sfx = "";
else if (i == 2) /* th_TH */
era = "\u0e1e.\u0e28. ", yr = yrb[k], sfx = "";
+ else if (i >= 3 && i <= 7) /* {zh,cmn,hak,nan,lzh}_TW */
+ {
+ era = (is_before (k, 1, 1, 1912)) ? "\u6c11\u524d"
+ : "\u6c11\u570b";
+ yr = yrc[k], sfx = "\u5e74";
+ }
else
assert (0); /* Unreachable. */
if (yr == 1)
--
2.12.2