webapp: parse rounded timestamps
authorHelmut Grohne <helmut@subdivi.de>
Wed, 6 Mar 2019 07:18:38 +0000 (08:18 +0100)
committerHelmut Grohne <helmut@subdivi.de>
Wed, 6 Mar 2019 07:18:38 +0000 (08:18 +0100)
webapp.py

index b9558cd..9e69a18 100644 (file)
--- a/webapp.py
+++ b/webapp.py
@@ -90,7 +90,10 @@ src_template = """<!DOCTYPE html>
 
 @app.template_filter("sqltimestamp")
 def sqltimestamp_filter(s):
-    return datetime.datetime.strptime(s, "%Y-%m-%d %H:%M:%S.%f")
+    try:
+        return datetime.datetime.strptime(s, "%Y-%m-%d %H:%M:%S.%f")
+    except ValueError:
+        return datetime.datetime.strptime(s, "%Y-%m-%d %H:%M:%S")
 
 @app.template_filter("formatts")
 def formatts_filter(ts):