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.
This commit is contained in:
TAMUKI Shoichi 2019-04-02 16:42:04 +09:00
parent 2f1d61552d
commit 84aea16929
3 changed files with 45 additions and 8 deletions

View File

@ -7,6 +7,14 @@
(mkreftable): Minor improvements to simplify maintenance.
(do_test): Reflect the changes in dates array.
[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.
2019-04-01 Carlos O'Donell <carlos@redhat.com>
* localedata/locales/ja_JP: Add comments to era entries.

View File

@ -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)

View File

@ -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)