1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-12 21:30:39 +00:00

Handle exception when converting timestamp to datetime in translate_seahub_time tag

This commit is contained in:
zhengxie
2014-06-21 11:05:30 +08:00
parent 536990add6
commit d3ef4b1b58

View File

@@ -169,7 +169,10 @@ def translate_seahub_time(value):
if isinstance(value, int) or isinstance(value, long): # check whether value is int
val_ts = value
val = datetime.fromtimestamp(val_ts) # convert timestamp to datetime
try:
val = datetime.fromtimestamp(val_ts) # convert timestamp to datetime
except ValueError as e:
return ""
elif isinstance(value, datetime):
# FIXME: convert datetime to timestamp may cause problem, need a better way.
val_ts = int(time.mktime(value.timetuple()))