Fix pretty_print_time_interval for MySQL. Fix #1619.

This commit is contained in:
Nicola Soranzo
2016-02-18 20:08:14 +00:00
parent 476734d865
commit ef93629719
+5 -1
View File
@@ -352,7 +352,11 @@ def pretty_print_time_interval( time=False, precise=False ):
elif isinstance( time, datetime ):
diff = now - time
elif isinstance( time, basestring ):
time = datetime.strptime( time, "%Y-%m-%dT%H:%M:%S.%f" )
try:
time = datetime.strptime( time, "%Y-%m-%dT%H:%M:%S.%f" )
except ValueError:
# MySQL may not support microseconds precision
time = datetime.strptime( time, "%Y-%m-%dT%H:%M:%S" )
diff = now - time
else:
diff = now - now