From patchwork Fri Jan 11 04:49:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: TAMUKI Shoichi X-Patchwork-Id: 1023383 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-99170-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linet.gr.jp Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="NsAR8y5f"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43bVmk206vz9sCX for ; Fri, 11 Jan 2019 15:50:46 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:message-id:from:date:to:subject:in-reply-to :references:mime-version:content-type; q=dns; s=default; b=b7HGk +4AvbcG0ZgsVsekfWOgMmupGb0JPLaVsvDDXUy+P1EfUZQzkOSxBsFxNcfvJqBRK WVfmJL63EZTO+tPVSk0yVCqujGeeCiJS5V/aqEL+3P94QcOM2v9y1G6gdn9e00Il YKJXapl1zTes/82UUycKJUBBZxqcHG4QupDLVU= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:message-id:from:date:to:subject:in-reply-to :references:mime-version:content-type; s=default; bh=GKrFlkHOLyw NVxNyv7MR2NyG91c=; b=NsAR8y5f0ON8u43hWQvptbgkmjTHniN9BBM5B/oQ8Sm eHZ60uahwXZiLnodgFmflZVawFX3mXCfOiqWAvKYeE4JAZaNgzvP74MBkaU020OS qapYlljPczR7AQprnFeATKkq6S/V8nyUKS3u+c5x8O4idsocBHpOO3pV75CLnT60 = Received: (qmail 77673 invoked by alias); 11 Jan 2019 04:50:41 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 77664 invoked by uid 89); 11 Jan 2019 04:50:40 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 spammy=lasts, Major, calendar, japanese X-HELO: mail.linet.jp Message-Id: <201901110449.AA04174@tamuki.linet.gr.jp> From: TAMUKI Shoichi Date: Fri, 11 Jan 2019 13:49:56 +0900 To: libc-alpha@sourceware.org Subject: [PATCH v6 1/2] strftime: Set the default width of "%Ey" to 2 [BZ #23758] In-Reply-To: <201901110447.AA04173@tamuki.linet.gr.jp> References: <201901110447.AA04173@tamuki.linet.gr.jp> MIME-Version: 1.0 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