diff --git a/hswaw/checkinator/at/templates/main.html b/hswaw/checkinator/at/templates/main.html index 6012b213..36ab1cd1 100644 --- a/hswaw/checkinator/at/templates/main.html +++ b/hswaw/checkinator/at/templates/main.html @@ -9,7 +9,7 @@ Now at hackerspace {% for user, timestamp in users %}
  • - {{ user }} ({{ timestamp|strfts() }}) + {{ user }} ({{ timestamp|strfts() }} UTC)
  • {% endfor %} @@ -31,4 +31,19 @@ Now at hackerspace {% endtrans %}
    Claim this device! + {% endblock %} diff --git a/hswaw/checkinator/at/tracker.py b/hswaw/checkinator/at/tracker.py index 18a139e9..4ca71fb8 100644 --- a/hswaw/checkinator/at/tracker.py +++ b/hswaw/checkinator/at/tracker.py @@ -7,7 +7,7 @@ import re import subprocess import logging from concurrent import futures -from datetime import datetime +from datetime import datetime, timezone from .tracker_pb2 import DhcpClient, DhcpClients, HwAddrResponse from .tracker_pb2_grpc import DhcpTrackerServicer, add_DhcpTrackerServicer_to_server @@ -22,7 +22,8 @@ logging.basicConfig(level=logging.INFO) def lease_to_client(lease: DhcpLease) -> DhcpClient: return DhcpClient( hw_address = bytes.fromhex(lease.hwaddr.replace(':', '')), - last_seen = datetime.utcfromtimestamp(lease.atime).isoformat(), + last_seen = datetime.utcfromtimestamp(lease.atime).replace( + tzinfo=timezone.utc).isoformat(), client_hostname = lease.name, ip_address = lease.ip ) diff --git a/hswaw/checkinator/at/web.py b/hswaw/checkinator/at/web.py index 9eb5e6a8..f85aa25b 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 @@ def app(instance_path, devices_api, config): @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')