[Zope-Checkins] CVS: Zope/lib/python/DateTime - DateTime.py:1.82.8.2

Andreas Jung andreas@andreas-jung.com
Sat, 30 Nov 2002 04:01:01 -0500


Update of /cvs-repository/Zope/lib/python/DateTime
In directory cvs.zope.org:/tmp/cvs-serv627

Modified Files:
      Tag: ajung-european-datetime-support-branch
	DateTime.py 
Log Message:
added envvar ENFORCE_DATETIME_FORMAT


=== Zope/lib/python/DateTime/DateTime.py 1.82.8.1 => 1.82.8.2 ===
--- Zope/lib/python/DateTime/DateTime.py:1.82.8.1	Sat Nov 30 03:37:04 2002
+++ Zope/lib/python/DateTime/DateTime.py	Sat Nov 30 04:01:00 2002
@@ -22,6 +22,11 @@
 try: from time import tzname
 except: tzname=('UNKNOWN','UNKNOWN')
 
+
+_default_datefmt = os.environ.get('ENFORCED_DATETIME_FORMAT', 'us').lower()
+if not _default_datefmt in ('us', 'international'):
+    raise ValueError, "ENFORCED_DATETIME_FORMAT must be either 'us' or 'international'"
+
 # To control rounding errors, we round system time to the nearest
 # millisecond.  Then delicate calculations can rely on that the
 # maximum precision that needs to be preserved is known.
@@ -613,7 +618,7 @@
         timezones recognized by the DateTime module. Recognition of
         timezone names is case-insensitive.""" #'
 
-        datefmt = kw.get('datefmt', 'us')
+        datefmt = kw.get('datefmt', _default_datefmt)
         assert datefmt in ('us', 'international')
 
         d=t=s=None