[issue29457] strftime('%x') does not use my locale

2017-02-06 Thread R. David Murray
R. David Murray added the comment: Yes, it is the default behavior, because the default locale, as for most (almost all?) programming languages (not just Python), is the C locale, until you change it. The reason for this is to get consistent behavior no matter what the locale is set to, unles

[issue29457] strftime('%x') does not use my locale

2017-02-05 Thread Hugo Osvaldo Barrera
Hugo Osvaldo Barrera added the comment: The problem is that the datetime/strftime documentation describes "%c" as: Locale’s appropriate date and time representation. However, this is not really accurate (this is not the *default* behaviour), that's why I was mentioning the clarification. I

[issue29457] strftime('%x') does not use my locale

2017-02-05 Thread Xiang Zhang
Xiang Zhang added the comment: I doubt the info belongs to datetime module documentation. When you encounter locale related problems maybe it's better for you to refer locale module documentation, and it mentions this behaviour https://docs.python.org/3/library/locale.html#background-details-h

[issue29457] strftime('%x') does not use my locale

2017-02-05 Thread Hugo Osvaldo Barrera
Hugo Osvaldo Barrera added the comment: It would seem that locale.setlocale(locale.LC_TIME, "") fixes the issue. However, there seems to be no mention on this on the relevant documentation page[1], which is actually the source of my confusion. As a "fix" to this issue (since I'm probably

[issue29457] strftime('%x') does not use my locale

2017-02-05 Thread Eryk Sun
Eryk Sun added the comment: As Martin said, you need to set the LC_TIME category using an empty string to use the locale LC_* environment variables. Python 3 sets LC_CTYPE at startup (on Unix platforms only), but LC_TIME is left in the initial C locale: >>> locale.setlocale(locale.LC_CTYPE

[issue29457] strftime('%x') does not use my locale

2017-02-05 Thread Martin Panter
Martin Panter added the comment: >>> datetime.now().strftime("%x") '02/06/17' >>> from locale import setlocale, LC_TIME >>> setlocale(LC_TIME) 'C' >>> setlocale(LC_TIME, "en_US.utf8") 'en_US.utf8' >>> datetime.now().strftime("%x") '02/06/2017' -- ___

[issue29457] strftime('%x') does not use my locale

2017-02-05 Thread Martin Panter
Martin Panter added the comment: Have you tried enabling the locale with locale.setlocale()? I believe Python only enables LC_CTYPE by default, so other locale aspects like LC_TIME won’t work until they are enabled. -- nosy: +martin.panter ___ Pytho

[issue29457] strftime('%x') does not use my locale

2017-02-05 Thread Hugo Osvaldo Barrera
New submission from Hugo Osvaldo Barrera: As the the posix spec for strftime: %c The preferred date and time representation for the current locale. %x The preferred date representation for the current locale without the time. However, python doesn't seem to respect this: $ python3.5 -c "fr