bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#55183: date


From: Pádraig Brady
Subject: bug#55183: date
Date: Fri, 29 Apr 2022 17:24:01 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:97.0) Gecko/20100101 Thunderbird/97.0

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





reply via email to

[Prev in Thread] Current Thread [Next in Thread]