From c8df32375aa39f19b5a5140d4da8ea467ef2ba52 Mon Sep 17 00:00:00 2001 From: Oscar Krause Date: Tue, 3 Jan 2023 21:49:24 +0100 Subject: [PATCH] fixed timezone handling --- app/main.py | 2 ++ app/static/assets/js/helper.js | 17 ++++++++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/app/main.py b/app/main.py index dc1cb02..828152b 100644 --- a/app/main.py +++ b/app/main.py @@ -15,6 +15,8 @@ from fastapi import FastAPI from fastapi.requests import Request from jose import jws, jwk, jwt, JWTError from jose.constants import ALGORITHMS +from starlette.middleware.cors import CORSMiddleware +from starlette.responses import StreamingResponse, JSONResponse, Response, RedirectResponse from sqlalchemy import create_engine from sqlalchemy.orm import sessionmaker from starlette.middleware.cors import CORSMiddleware diff --git a/app/static/assets/js/helper.js b/app/static/assets/js/helper.js index 90f3e8d..d1fd912 100644 --- a/app/static/assets/js/helper.js +++ b/app/static/assets/js/helper.js @@ -49,6 +49,17 @@ async function fetchOriginsWithLeases(element) { } async function fetchLeases(element) { + // datetime config + const dtc = { + year: "numeric", + month: "2-digit", + day: "2-digit", + hour: "2-digit", + minute: "2-digit", + second: "2-digit", + timeZoneName: "short" + } + let xhr = new XMLHttpRequest(); xhr.open("GET", '/-/leases?origin=true', true); xhr.onreadystatechange = function () { @@ -74,9 +85,9 @@ async function fetchLeases(element) { let row = document.createElement('tr'); row.innerHTML = ` ${o.lease_ref} - ${o.lease_created} - ${o.lease_updated} - ${o.lease_expires} + ${new Date(o.lease_created).toLocaleDateString('system', dtc)} + ${new Date(o.lease_updated).toLocaleDateString('system', dtc)} + ${new Date(o.lease_expires).toLocaleDateString('system', dtc)} ${o.origin_ref}` tbody.appendChild(row); })