--- a/utils.py Tue Feb 17 22:45:55 2009 +0100
+++ b/utils.py Tue Feb 17 22:59:14 2009 +0100
@@ -6,6 +6,7 @@
"""
__docformat__ = "restructuredtext en"
+import locale
from md5 import md5
from time import time
from random import randint, seed
@@ -42,6 +43,16 @@
yield date
date += incr
+def ustrftime(date, fmt='%Y-%m-%d'):
+ """like strftime, but returns a unicode string instead of an encoded
+ string which may be problematic with localized date.
+
+ encoding is guessed by locale.getpreferredencoding()
+ """
+ # date format may depend on the locale
+ encoding = locale.getpreferredencoding(do_setlocale=False) or 'UTF-8'
+ return unicode(date.strftime(fmt), encoding)
+
def dump_class(cls, clsname):
"""create copy of a class by creating an empty class inheriting