Issue 898253: strftime ignores date format on winxp (original) (raw)

Created on 2004-02-16 20:19 by matiu, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (5)
msg20013 - (view) Author: Matthew Sherborne (matiu) Date: 2004-02-16 20:19
On Windows XP in the control panel set your country to "New Zealand". This gives a short date format of 'dd-mm-yy' Now in python: >>> from time import * >>> print strftime('%c', localtime) 02/17/04 09:15:10 >>> print strftime('%x', localtime()) 02/17/04 This is giving the date in the format 'mm-dd-yy' (American). Could it be to do with the 'locale.nl_langinfo' bieng unavailable in xp? Versions: ActivePython 2.3.2 Build 232 (ActiveState Corp.) based on Python 2.3.2 (#49, Nov 13 2003, 10:34:54) [MSC v.1200 32 bit (Intel)] on win32 Windows XP Home Edition (up to dateish)
msg20014 - (view) Author: Matthew Sherborne (matiu) Date: 2004-02-16 20:29
Logged In: YES user_id=304464 Sorry, code should be: >>> from time import * >>> print strftime('%c', localtime()) 02/17/04 09:15:10 >>> print strftime('%x', localtime()) 02/17/04
msg20015 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2004-02-17 21:50
Logged In: YES user_id=357491 This is a Windows C library bug and nothing to do with our end. Since time.strftime is just a wrapper around ISO C's strftime function we just pass in the arguments and then pass them back out without fiddling with anything. So unless there is some compiler setting that needs to be set to be more locale-sensitive (doubt it, but since I don't have a Windows box I have no way of knowing; this is why I am unassigning this from myself) this is probably invalid and Microsoft's fault.
msg20016 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2004-03-14 06:04
Logged In: YES user_id=80475 Tim, what do you think?
msg20017 - (view) Author: Tim Peters (tim.peters) * (Python committer) Date: 2004-03-14 06:18
Logged In: YES user_id=31435 I think it's a feature that locale-dependent behavior defaults to "C" locale, and doesn't change unless you explicitly change the locale. >>> import time, locale >>> now = time.localtime() >>> time.strftime("%c", now) '03/14/04 01:14:52' >>> locale.setlocale(locale.LC_ALL, "german") 'German_Germany.1252' >>> time.strftime("%c", now) # that changed what "%c" does '14.03.04 01:14:52' >>> I also think C's locale gimmicks suck (e.g., there's no portable set of locale names across platforms), but that's all we've got for now. IOW, this isn't a bug.
History
Date User Action Args
2022-04-11 14:56:02 admin set github: 39942
2004-02-16 20:19:02 matiu create