bug#55183: date

2022-04-29 Thread Pádraig Brady

tag 55183 notabug
close 55183
stop

On 29/04/2022 13:59, danilopereira82--- via GNU coreutils Bug Reports wrote:

%r has a space at the end that makes me insanely angry fix it


What's happening is there is no "am_pm" item defined for your locale.
Running this with a locale that does define it, you can see:

  $ LC_TIME=C date +%r
  05:00:50 PM

  $ LC_TIME=zh_CN.utf8 date +%r
  下午 05时00分50秒

You can look up these values with:

  $ LC_TIME=C locale t_fmt_ampm t_fmt am_pm
  %I:%M:%S %p
  %H:%M:%S
  AM;PM

Note "t_fmt_ampm" if defined, takes precedence over "t_fmt ampm".

You could argue that an empty ampm should not output the space,
but that would have to be addressed in the libc strftime() implementation.

Another option is to use the more abstract %X format
to get the time in the most appropriate for one's locale,
which should be setup appropriately for locales that don't use AM/PM.

  $ LC_ALL=C date +%X
  17:00:50
  $ LC_ALL=en_US.utf8 date +%X
  05:00:50 PM
  $ LC_ALL=pt_PT.utf8 date +%X
  17:00:50

cheers,
Pádraig





bug#55183: date

2022-04-29 Thread danilopereira82--- via GNU coreutils Bug Reports
%r has a space at the end that makes me insanely angry fix it