unofficial mirror of libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Rafal Luzynski <digitalfreak@lingonborough.com>
To: libc-alpha@sourceware.org
Cc: TAMUKI Shoichi <tamuki@linet.gr.jp>,
	Felix Yan <felixonmars@archlinux.org>
Subject: [PATCH 3/3] time: Add tests for Minguo calendar [BZ #24293]
Date: Fri, 15 Mar 2019 12:49:27 +0100 (CET)	[thread overview]
Message-ID: <1517391513.248381.1552650568043@poczta.nazwa.pl> (raw)
In-Reply-To: <988338284.248045.1552650382964@poczta.nazwa.pl>

	[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(-)

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 <stdio.h>
 #include <string.h>
 
-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" };
 
 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.  */
-- 
2.7.5

  parent reply	other threads:[~2019-03-15 11:49 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-15 11:46 [PATCH 0/3] Additional changes after introducing Minguo calendar and zero-padding in %Ey Rafal Luzynski
2019-03-15 11:47 ` [PATCH 1/3] NEWS: Mention Minguo calendar support added [BZ #24293] Rafal Luzynski
2019-03-17 10:28   ` TAMUKI Shoichi
2019-03-18 23:24     ` Rafal Luzynski
2019-03-15 11:48 ` [PATCH 2/3] time/tst-strftime2.c: Make the file easier to maintain Rafal Luzynski
2019-03-17 10:32   ` TAMUKI Shoichi
2019-03-18 23:30     ` Rafal Luzynski
2019-03-20  9:19       ` TAMUKI Shoichi
2019-03-27  3:28   ` TAMUKI Shoichi
2019-03-15 11:49 ` Rafal Luzynski [this message]
2019-03-15 11:53   ` [PATCH 3/3] time: Add tests for Minguo calendar [BZ #24293] Rafal Luzynski
2019-03-17 10:35   ` TAMUKI Shoichi
2019-03-18 23:35     ` Rafal Luzynski
2019-03-20  9:21       ` TAMUKI Shoichi
2019-03-24 11:40         ` TAMUKI Shoichi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/libc/involved.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1517391513.248381.1552650568043@poczta.nazwa.pl \
    --to=digitalfreak@lingonborough.com \
    --cc=felixonmars@archlinux.org \
    --cc=libc-alpha@sourceware.org \
    --cc=tamuki@linet.gr.jp \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).