On 12/05/15 17:55, Marko Myllynen wrote:
> Hi,
> 
> [CC'ing Keld with whom this issue was discussed some years ago]
> 
> On 2015-05-12 18:49, Pádraig Brady wrote:
>> On 12/05/15 16:40, Pádraig Brady wrote:
>>> On 12/05/15 14:51, Michael Stone wrote:
>>>> On Tue, May 12, 2015 at 03:36:17PM +0200, op...@mumm.ac.be wrote:
>>>>> I'm just upgrading my server from debian 7 (wheezy) to debian 8 (jessie) 
>>>>> and several of my scripts are not working anymore. After some tests, it 
>>>>> turns out that the problem likely comes from the fact the 'date' function 
>>>>> does not work as expected.
>>>>>
>>>>> In wheezy, the command line
>>>>>> date /bin/date +"%Y%m%d.%p"
>>>>> would have returned
>>>>>> 20150512.PM
>>>>>
>>>>> In jessie, the same command line returns
>>>>>> 20150512.
>>>>> omitting PM.
>>>>>
>>>>> As a consequence of this omission, my scripts are crashing.
>>>>>
>>>>> Have you got any idea why this is happening?
>>>>
>>>> I can't reproduce it:
>>>>
>>>>> /bin/date +"%Y%m%d.%p"
>>>> 20150512.AM
>>>>
>>>> If I had to guess, I'd say it's a locale issue. What does 
>>>> env LANG=C LC_ALL=C /bin/date +"%Y%m%d.%p"
>>>> return?
>>>>
>>>> If that works, what does 
>>>> locale
>>>> return when run by itself?
>>>
>>> %p is blank in many locales unfortunately.
>>> You can see the am_pm vary with these commands:
>>>
>>> $ LC_ALL=en_IE locale -k LC_TIME
>>> $ LC_TIME=C locale -k LC_TIME
>>> $ LC_ALL=zh_CN.utf8 date +%p
>>> 下午
>>> $ LC_ALL=en_US.utf8 date +%p
>>> PM
>>> $ LC_ALL=en_US date +%p
>>> PM
>>>
>>> locales with blank am_pm should be fixed up to allow one to
>>> get an explicit 12 hour format like `date +%I:%m%p` for example.
>>>
>>> Note some locales (like en_GB for example) default
>>> to 24 hour (t_fmt="%T"), and also provide an am_pm entry,
>>> which is the correct behavior in my opinion.
>>
>> I see that https://sourceware.org/glibc/wiki/Locales states:
>> "am_pm and t_fmt_ampm - should be empty if using 24 hour time"
>>
>> Marko, that seems incorrect?
>> At least am_pm should be populated to
>> allow users to generate 12 hour time with strftime?
> 
> I can't find references to the discussion I had with Keld earlier but
> the rationale for not populating it was along the lines:
> 
> 1) am_pm should be populated only if AM/PM convention is used to signal
> applications they should not try to print them when using them is
> unwanted. Seems that only the locale(5) commit messages, not the page
> itself, spell this out:
> 
> http://git.kernel.org/cgit/docs/man-pages/man-pages.git/commit/?id=b5d4168adfb426f45108ac2bf7c8b17b126b07a1
> http://git.kernel.org/cgit/docs/man-pages/man-pages.git/commit/?id=0c2dbad182e40db2ca47128f229ca7dbd83e179f
> 
> 2) what "unwanted" means is that in many cases 12 hour time with AM/PM
> notation is alien thus generating such time representation under those
> locales would be illogical (e.g. "5.34 ip." in Finnish context is
> completely unnatural).
> 
> The same goes for various name_* keywords in LC_NAME, defining them for
> locales where they are not used would not allow signaling applications
> that under those locales their usage is unwanted.

Thanks for the info.

Generally apps would not need to know whether to select
between 12 and 24?  Can't they just use the higher level
(and POSIX defined) %X to get the appropriate default?

I propose the wiki at least should be reworded to
state that am_pm should be omitted only when
it doesn't make any sense, like in Finland for example?

Also we'll need to fix up some locales that may have
blindly followed the existing advice.

The 12h format is not appropriate for Ireland at least:

$ LC_TIME=en_IE date +'def: %X | 12h: %r | 24h: %T'
def: 18:19:52 | 12h: 06:19:52  | 24h: 18:19:52

cheers,
Pádraig.


-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to