Issue 5997: strftime is broken (original) (raw)
Issue5997
Created on 2009-05-11 17:58 by jonathan.cervidae, last changed 2022-04-11 14:56 by admin. This issue is now closed.
Messages (3) | ||
---|---|---|
msg87582 - (view) | Author: Jonathan (jonathan.cervidae) | Date: 2009-05-11 17:58 |
[jon@jaydee Development]$ cat is-strftime-broken.py #!/usr/bin/env python import subprocess import time date_process = subprocess.Popen( ("date", "+%x"), stdout=subprocess.PIPE) from_date_command = date_process.communicate()[0].rstrip() from_strftime = time.strftime("%x") print "Date command returns %s, strftime returns %s" % ( from_date_command, from_strftime ) [jon@jaydee Development]$ python ./is-strftime-broken.py Date command returns 11/05/09, strftime returns 05/11/09 | ||
msg87584 - (view) | Author: R. David Murray (r.david.murray) * ![]() |
Date: 2009-05-11 19:52 |
Please read http://docs.python.org/library/locale.html specifically the docs for 'setlocale'. Before you call setlocale, python's locale is 'C', just like for any C program before it calls setlocale. Python 2.6.2 (r262:71600, May 2 2009, 15:06:57) [GCC 4.3.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import locale >>> import time >>> time.strftime("%x") '05/11/09' >>> locale.setlocale(locale.LC_ALL,"") 'tr_TR.utf-8' >>> time.strftime("%x") '11-05-2009' | ||
msg87594 - (view) | Author: Jonathan (jonathan.cervidae) | Date: 2009-05-11 22:52 |
Works perfectly now, thank you and sorry for the inaccurate report. |
History | |||
---|---|---|---|
Date | User | Action | Args |
2022-04-11 14:56:48 | admin | set | github: 50247 |
2009-05-11 22:52:18 | jonathan.cervidae | set | messages: + |
2009-05-11 19:52:42 | r.david.murray | set | status: open -> closednosy: + r.david.murraymessages: + resolution: not a bug |
2009-05-11 17:58:26 | jonathan.cervidae | create |