provide localization of datetime values if pytz module is present: error handling
This commit is contained in:
parent
2f6cb9ac69
commit
83732349a7
1 changed files with 5 additions and 2 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue