This is the mail archive of the
mailing list for the glibc project.
Re: [PATCH] Improve the width of alternate representation for year in strftime [BZ #23758]
- From: Florian Weimer <fweimer at redhat dot com>
- To: TAMUKI Shoichi <tamuki at linet dot gr dot jp>
- Cc: libc-alpha at sourceware dot org
- Date: Tue, 23 Oct 2018 14:54:04 +0200
- Subject: Re: [PATCH] Improve the width of alternate representation for year in strftime [BZ #23758]
- References: <201810112107.AA04060@tamuki.linet.gr.jp>
* TAMUKI Shoichi:
> The Japanese era name is scheduled to be changed on May 1, 2019.
> Prior to this, change the alternate 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, it
> is rare that the year ends in one digit or lasts more than three
> digits. In addition, the width of month, day, hour, minute, and
> second is 2, so adjust the width of year the same as them, the whole
> display balance is improved. Therefore, it would be reasonable to
> change the width padding with zero of %Ey default to 2.
> In glibc, besides ja_JP locale, the locales currently using the
> conversion specifier above are lo_LA (Laos) and th_TH (Thailand). In
> these locales, they use the Buddhist era. The Buddhist era is a value
> obtained by adding 543 to the Christian era, so it is not affected by
> this change of the conversion specifier %Ey.
> Furthermore, for the output string of the conversion specifier %EY,
> an optional flag is given to the conversion specifier so that it can
> be also used the current non-padding format, and the padding format
> can be controlled. To achieve this, when an optional flag is given to
> the conversion specifier %EY, processing is performed as the flag to
> be given to %Ey included in the combined conversion specifier.
Thanks for this suggestion. To you have a copyright assignment for
glibc on file?
It looks like that there are two changes (plus some formatting cleanups)
in this patch: the change in padding:
> - DO_NUMBER (1, (era->offset
> + DO_NUMBER (2, (era->offset
> + delta * era->absolute_direction));
and adding a way to override the padding, when %EY is exanded using
locale data, rewriting the %Ey contained in the format string.
I think the second part should be handled differently, by not rewriting
the format string, and rather adding strftime arguments (possibly in a
struct) to set the default padding.
This should also avoid the need for new memory allocations.