diff options
author | TAMUKI Shoichi <tamuki@linet.gr.jp> | 2019-04-02 16:42:04 +0900 |
---|---|---|
committer | TAMUKI Shoichi <tamuki@linet.gr.jp> | 2019-04-02 16:42:04 +0900 |
commit | 84aea16929f310625a52bf9c3db3341f56970ab0 (patch) | |
tree | 1a5fd364597665257798e8ed976a06afd29dc2b1 /time | |
parent | 2f1d61552d429c4e1cbcec115f3cc3dcaf91400d (diff) | |
download | glibc-84aea16929f310625a52bf9c3db3341f56970ab0.tar.gz |
time: Add tests for Minguo calendar [BZ #24293]
Co-authored-by: Rafal Luzynski <digitalfreak@lingonborough.com>
Reviewed-by: Carlos O'Donell <carlos@redhat.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.
Diffstat (limited to 'time')
-rw-r--r-- | time/Makefile | 4 | ||||
-rw-r--r-- | time/tst-strftime2.c | 41 |
2 files changed, 37 insertions, 8 deletions
diff --git a/time/Makefile b/time/Makefile index 2ca206309d..a428f55245 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 be15c773a4..0f371d972b 100644 --- a/time/tst-strftime2.c +++ b/time/tst-strftime2.c @@ -29,13 +29,16 @@ 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" }; /* Must match locale index into locales array. */ enum { - ja_JP, lo_LA, th_TH + ja_JP, lo_LA, th_TH, + zh_TW, cmn_TW, hak_TW, nan_TW, lzh_TW }; static const char *formats[] = { "%EY", "%_EY", "%-EY" }; @@ -47,12 +50,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)] @@ -81,12 +90,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++) @@ -95,14 +113,23 @@ mkreftable (void) { if (i == 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 == lo_LA) era = "\u0e9e.\u0eaa. ", yr = yrb[k], sfx = ""; else if (i == th_TH) era = "\u0e1e.\u0e28. ", yr = yrb[k], sfx = ""; + else if (i == zh_TW || i == cmn_TW || i == hak_TW + || i == nan_TW || i == lzh_TW) + { + era = (is_before (k, 1, 1, 1912)) ? "\u6c11\u524d" + : "\u6c11\u570b"; + yr = yrc[k], sfx = "\u5e74"; + } else FAIL_EXIT1 ("Invalid table index!"); if (yr == 1) |