This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH v6 1/2] strftime: Set the default width of "%Ey" to 2 [BZ #23758]


The Japanese era name is scheduled to be changed on May 1, 2019.
Prior to this, change the alternative representation for year in
strftime to pad the number with zero to keep it constant width, so
that prevent the trouble we saw in the past from becoming obvious
again from the year after the era name changes onward.

Since only one Japanese era name is used by each emperor's reign as
lately, it is rare that the year ends in one digit or lasts more than
three digits.  In addition, the default width of month, day, hour,
minute, and second is 2, so adjust the default width of year the same
as them, and then the whole display balance is improved.  Therefore,
it would be reasonable to set the default width padding with zero of
"%Ey" to 2.

ChangeLog:

	[BZ #23758]
	* NEWS: Mention the change.
	* manual/time.texi (strftime): Document the desctiption for "%Ey".
	Also, fix the wording to "alternative" rather than "alternate".
	* time/strftime_l.c (__strftime_internal): Set the default width
	padding with zero of "%Ey" to 2.
---
 NEWS              |  4 ++++
 manual/time.texi  | 11 ++++++++---
 time/strftime_l.c |  2 +-
 3 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/NEWS b/NEWS
index cc20102fda4..00fab6e8825 100644
--- a/NEWS
+++ b/NEWS
@@ -52,6 +52,10 @@ Major new features:
     - C-SKY ABIV2 soft-float little-endian
     - C-SKY ABIV2 hard-float little-endian
 
+* Improve the width of alternative representation for year in
+  strftime.  For %Ey conversion specifier, the default action is now
+  to pad the number with zero to keep minimum 2 digits, similar to %y.
+
 Deprecated and removed features, and other changes affecting compatibility:
 
 * The glibc.tune tunable namespace has been renamed to glibc.cpu and the
diff --git a/manual/time.texi b/manual/time.texi
index 9e981314876..ab544e590c8 100644
--- a/manual/time.texi
+++ b/manual/time.texi
@@ -1339,7 +1339,7 @@ POSIX.2-1992 and by @w{ISO C99}, are:
 
 @table @code
 @item E
-Use the locale's alternate representation for date and time.  This
+Use the locale's alternative representation for date and time.  This
 modifier applies to the @code{%c}, @code{%C}, @code{%x}, @code{%X},
 @code{%y} and @code{%Y} format specifiers.  In a Japanese locale, for
 example, @code{%Ex} might yield a date format based on the Japanese
@@ -1347,7 +1347,7 @@ Emperors' reigns.
 
 @item O
 With all format specifiers that produce numbers: use the locale's
-alternate numeric symbols.
+alternative numeric symbols.
 
 With @code{%B}, @code{%b}, and @code{%h}: use the grammatical form for
 month names that is appropriate when the month is named by itself,
@@ -1355,7 +1355,7 @@ rather than the form that is appropriate when the month is used as
 part of a complete date.  This is a GNU extension.
 @end table
 
-If the format supports the modifier but no alternate representation
+If the format supports the modifier but no alternative representation
 is available, it is ignored.
 
 The conversion specifier ends with a format specifier taken from the
@@ -1568,6 +1568,11 @@ The preferred time of day representation for the current locale.
 The year without a century as a decimal number (range @code{00} through
 @code{99}).  This is equivalent to the year modulo 100.
 
+If the @code{E} modifier is specified (@code{%Ey}), the locale's
+alternative representation for year (the era year) is used instead.
+The default action is to pad the number with zero to keep minimum 2
+digits, similar to @code{%y}.
+
 @item %Y
 The year as a decimal number, using the Gregorian calendar.  Years
 before the year @code{1} are numbered @code{0}, @code{-1}, and so on.
diff --git a/time/strftime_l.c b/time/strftime_l.c
index 7ba4179de3e..cbe08e7afb4 100644
--- a/time/strftime_l.c
+++ b/time/strftime_l.c
@@ -1294,7 +1294,7 @@ __strftime_internal (CHAR_T *s, size_t maxsize, const CHAR_T *format,
 	      if (era)
 		{
 		  int delta = tp->tm_year - era->start_date[0];
-		  DO_NUMBER (1, (era->offset
+		  DO_NUMBER (2, (era->offset
 				 + delta * era->absolute_direction));
 		}
 #else
-- 
2.12.2


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]