[issue29457] strftime('%x') does not use my locale
Eryk Sun
report at bugs.python.org
Mon Feb 6 01:59:10 EST 2017
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, None)
'en_DK.UTF-8'
>>> locale.setlocale(locale.LC_TIME, None)
'C'
>>> time.strftime('%x')
'02/06/17'
>>> locale.setlocale(locale.LC_TIME, "")
'en_DK.UTF-8'
>>> time.strftime('%x')
'2017-02-06'
----------
nosy: +eryksun
resolution: -> not a bug
stage: -> resolved
status: open -> closed
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue29457>
_______________________________________
More information about the Python-bugs-list
mailing list