[Zope-Checkins] CVS: Zope/lib/python/DateTime - DateTime.py:1.82.8.4
Andreas Jung
andreas@andreas-jung.com
Tue, 3 Dec 2002 10:10:12 -0500
Update of /cvs-repository/Zope/lib/python/DateTime
In directory cvs.zope.org:/tmp/cvs-serv3637
Modified Files:
Tag: ajung-european-datetime-support-branch
DateTime.py
Log Message:
added support to get date format from locales
=== Zope/lib/python/DateTime/DateTime.py 1.82.8.3 => 1.82.8.4 ===
--- Zope/lib/python/DateTime/DateTime.py:1.82.8.3 Tue Dec 3 09:54:24 2002
+++ Zope/lib/python/DateTime/DateTime.py Tue Dec 3 10:10:11 2002
@@ -22,8 +22,17 @@
try: from time import tzname
except: tzname=('UNKNOWN','UNKNOWN')
+# sniff into locales to determine datetime format
+_default_fmt = 'us'
-_default_datefmt = os.environ.get('DATETIME_FORMAT', 'us').lower()
+try:
+ import locale
+ loc = locale.setlocale(locale.LC_ALL) # get current locale
+ fmt = locale.nl_langinfo(locale.D_FMT)
+ if fmt.startswith('%d'): _default_fmt = 'international'
+except: pass
+
+_default_datefmt = os.environ.get('DATETIME_FORMAT', _default_fmt).lower()
if not _default_datefmt in ('us', 'international'):
raise ValueError, "DATETIME_FORMAT must be either 'us' or 'international'"