hswaw/checkinator: convert timestamp to browsers timezone
Change-Id: Ib7439269bf13de530a5f170bf231f89d815b0f3e
Reviewed-on: https://gerrit.hackerspace.pl/c/hscloud/+/1246
Reviewed-by: q3k <q3k@hackerspace.pl>
diff --git a/hswaw/checkinator/at/web.py b/hswaw/checkinator/at/web.py
index 9eb5e6a..f85aa25 100644
--- a/hswaw/checkinator/at/web.py
+++ b/hswaw/checkinator/at/web.py
@@ -1,7 +1,7 @@
import json
import sqlite3
from pathlib import Path
-from datetime import datetime
+from datetime import datetime, timezone
from typing import NamedTuple, Iterable, Iterator, List
from functools import wraps
from flask import Flask, render_template, abort, g, \
@@ -112,8 +112,13 @@
@app.template_filter('strfts')
- def strfts(ts, format='%d/%m/%Y %H:%M'):
- return datetime.fromtimestamp(ts).strftime(format)
+ def strfts(ts, format='%Y-%m-%d %H:%M'):
+ return datetime.utcfromtimestamp(ts).strftime(format)
+
+ @app.template_filter('utcisoformat')
+ def utcisoformat(ts):
+ return datetime.utcfromtimestamp(ts).replace(
+ tzinfo=timezone.utc).isoformat()
@app.template_filter('wikiurl')