this should be a bug, date +%X

C de-Avillez hggdh2 at ubuntu.com
Sat Oct 13 00:37:30 UTC 2012


On 12/10/12 17:57, J wrote:
> On Fri, Oct 12, 2012 at 6:07 PM, Evuraan <evuraan at gmail.com> wrote:
>> man date says:
>>
>>        %X     locale’s time representation (e.g., 23:13:48)
>>
>> date (GNU coreutils) 7.4 gives:
>>
>> $ date +%X
>> 03:04:42 PM
>> ^^           ^^^^^------- this
>>
>> instead it should just be
>>
>> $ date +%X
>> 15:04:42
> 
> No it shouldn't... check your locale.  For example, en_US:
> 
> % Appropriate time representation (%X)
> %       "%r"
> t_fmt   "<U0025><U0072>"
> %
> % Appropriate AM/PM time representation (%r)
> %       "%I:%M:%S %p"
> t_fmt_ampm "<U0025><U0049><U003A><U0025><U004D><U003A><U0025><U0053><U0020>/
> <U0025><U0070>"
> 
> 
> This tells date that the appropriate time representation for the en_US
> locale is exactly what you are seeing.
> 

Indeed, and expected, coreutils respects locale. A quick check shows:

[cerdea-aws]cerdea at xango3:/build/buildd$ env LC_TIME="en_US.UTF-8"
date +%X



07:35:36 PM
[cerdea-aws]cerdea at xango3:/build/buildd$ env LC_TIME="en_DK.UTF-8"
date +%X



19:35:48
[cerdea-aws]cerdea at xango3:/build/buildd$ date --version
date (GNU coreutils) 8.13
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
<http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by David MacKenzie.
[cerdea-aws]cerdea at xango3:/build/buildd$

..C..



-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 897 bytes
Desc: OpenPGP digital signature
URL: <https://lists.ubuntu.com/archives/ubuntu-users/attachments/20121012/093a69ef/attachment.sig>


More information about the ubuntu-users mailing list