provide localization of datetime values if pytz module is present: error handling

This commit is contained in:
Helmut Merz 2013-03-11 11:43:12 +01:00
parent 2f6cb9ac69
commit 83732349a7

View file

@ -72,7 +72,10 @@ def year(d=None):
def toLocalTime(d):
if pytz is None:
if pytz is None or not d:
return d
cet = pytz.timezone('CET')
return d.astimezone(cet)
try:
return d.astimezone(cet)
except ValueError:
return d