[Baypiggies] strftime("%x") inconsistent?

Paul McNett p at ulmcnett.com
Tue Nov 10 00:30:21 CET 2009


I'm using python 2.5.4 (sorry, been meaning to go to 2.6 or 2.7 but I've been too 
busy to take the plunge yet, and I can't consider going to 3.x until there's more 
3rd-party lib support).

Anyway, I want to give a textual representation of a date or datetime using the 
user's current locale setting. I don't want to explicitly set the format as I think 
this should be up to the user.

The following code results in the expected output (match the 'short date' format in 
Control Panel/Regional Settings) on Windows XP, but not on Mac 10.5.7 or Ubuntu 8.04:

import locale
import datetime
import time

locale.setlocale(locale.LC_ALL, "")

d = datetime.date.today()

print time.strftime("%x", d.timetuple())

Am I forgetting a step?


More information about the Baypiggies mailing list