[Zope-Checkins] CVS: Zope/lib/python/DateTime -
DateTime.py:1.85.12.8
Andreas Jung
andreas at andreas-jung.com
Tue Mar 2 12:25:36 EST 2004
Update of /cvs-repository/Zope/lib/python/DateTime
In directory cvs.zope.org:/tmp/cvs-serv23682/lib/python/DateTime
Modified Files:
Tag: Zope-2_7-branch
DateTime.py
Log Message:
- The DateTime module did not recognize the settings for
"datetime-format".
=== Zope/lib/python/DateTime/DateTime.py 1.85.12.7 => 1.85.12.8 ===
--- Zope/lib/python/DateTime/DateTime.py:1.85.12.7 Thu Jan 1 13:01:57 2004
+++ Zope/lib/python/DateTime/DateTime.py Tue Mar 2 12:25:35 2004
@@ -20,6 +20,7 @@
from time import daylight, timezone, altzone, strftime
from types import InstanceType, IntType, FloatType, StringType, UnicodeType
+
try:
from time import tzname
except:
@@ -37,9 +38,40 @@
class TimeError( DateTimeError ):
pass
-_default_datefmt = os.environ.get('DATETIME_FORMAT', "us").lower()
-if not _default_datefmt in ('us', 'international'):
- raise ValueError, "DATETIME_FORMAT must be either 'us' or 'international'"
+from App.config import getConfiguration
+
+default_datefmt = None
+
+def getDefaultDateFormat():
+ global default_datefmt
+ if default_datefmt is None:
+ try:
+ default_datefmt = getConfiguration().datetime_format
+ return default_datefmt
+ except:
+ return 'us'
+ else:
+ return default_datefmt
+
+
+try:
+ from time import tzname
+except:
+ tzname=('UNKNOWN','UNKNOWN')
+
+class DateTimeError( Exception ):
+ pass
+
+class SyntaxError( DateTimeError ):
+ pass
+
+class DateError( DateTimeError ):
+ pass
+
+class TimeError( DateTimeError ):
+ pass
+
+
# To control rounding errors, we round system time to the nearest
# millisecond. Then delicate calculations can rely on that the
@@ -244,7 +276,7 @@
'bt':'GMT+3', 'zp4':'GMT+4', 'zp5':'GMT+5', 'zp6':'GMT+6',
'wast':'GMT+7', 'cct':'GMT+8', 'jst':'GMT+9', 'east':'GMT+10',
'gst':'GMT+10', 'nzt':'GMT+12', 'nzst':'GMT+12', 'idle':'GMT+12',
- 'ret':'GMT+4'
+ 'ret':'GMT+4', 'ist': 'GMT+0530'
}
def __init__(self):
@@ -279,7 +311,7 @@
localzone = altzone
else:
localzone = timezone
- offset=(-localzone/(60*60))
+ offset=(-localzone/(60*60.0))
majorOffset=int(offset)
if majorOffset != 0 :
minorOffset=abs(int((offset % majorOffset) * 60.0))
@@ -648,9 +680,7 @@
timezones recognized by the DateTime module. Recognition of
timezone names is case-insensitive.""" #'
- datefmt = kw.get('datefmt', _default_datefmt)
- assert datefmt in ('us', 'international')
-
+ datefmt = kw.get('datefmt', getDefaultDateFormat())
d=t=s=None
ac=len(args)
millisecs = None
@@ -899,7 +929,7 @@
tz = self.localZone(ltm)
return tz
- def _parse(self,st, datefmt=_default_datefmt):
+ def _parse(self,st, datefmt=getDefaultDateFormat()):
# Parse date-time components from a string
month=year=tz=tm=None
spaces =self.space_chars
More information about the Zope-Checkins
mailing list