Use local timezone on dashboard
This commit is contained in:
parent
a4f205290d
commit
9eaba2e77a
@ -5,8 +5,8 @@
|
|||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<title>Temperature-Alarm-Web</title>
|
<title>Temperature-Alarm-Web</title>
|
||||||
<script defer src="https://cdn.jsdelivr.net/npm/chart.js"></script>
|
<script defer src="https://cdn.jsdelivr.net/npm/chart.js"></script>
|
||||||
<script defer src="https://cdn.jsdelivr.net/npm/moment"></script>
|
<script defer src="https://cdn.jsdelivr.net/npm/luxon"></script>
|
||||||
<script defer src="https://cdn.jsdelivr.net/npm/chartjs-adapter-moment"></script>
|
<script defer src="https://cdn.jsdelivr.net/npm/chartjs-adapter-luxon"></script>
|
||||||
<script defer type="module" src="/scripts/home.js"></script>
|
<script defer type="module" src="/scripts/home.js"></script>
|
||||||
<link rel="stylesheet" href="/styles/common.css">
|
<link rel="stylesheet" href="/styles/common.css">
|
||||||
<link rel="stylesheet" href="/styles/home.css" />
|
<link rel="stylesheet" href="/styles/home.css" />
|
||||||
|
@ -29,8 +29,9 @@ function buildTable(data, offset = 0) {
|
|||||||
color = "tempNormal";
|
color = "tempNormal";
|
||||||
}
|
}
|
||||||
|
|
||||||
const date = new Date(log.date).toLocaleDateString();
|
const parsedDate = luxon.DateTime.fromISO(log.date).setZone("Europe/Copenhagen").setLocale("gb");
|
||||||
const time = new Date(log.date).toLocaleTimeString();
|
const date = parsedDate.toLocaleString(luxon.DateTime.DATE_SHORT);
|
||||||
|
const time = parsedDate.toLocaleString(luxon.DateTime.TIME_WITH_SECONDS);
|
||||||
|
|
||||||
document.getElementById("table-body").innerHTML += `
|
document.getElementById("table-body").innerHTML += `
|
||||||
<tr>
|
<tr>
|
||||||
@ -81,11 +82,17 @@ function isSameDay(a, b) {
|
|||||||
a.getDate() === b.getDate();
|
a.getDate() === b.getDate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function localToUTC(date) {
|
||||||
|
if (!date) return null;
|
||||||
|
|
||||||
|
return luxon.DateTime.fromISO(date, { zone: "Europe/Copenhagen" }).setZone("UTC");
|
||||||
|
}
|
||||||
|
|
||||||
async function fetchData() {
|
async function fetchData() {
|
||||||
document.body.classList.add("loading");
|
document.body.classList.add("loading");
|
||||||
|
|
||||||
const startDate = document.getElementById("period-start").value;
|
const startDate = localToUTC(document.getElementById("period-start").value);
|
||||||
const endDate = document.getElementById("period-end").value;
|
const endDate = localToUTC(document.getElementById("period-end").value);
|
||||||
|
|
||||||
const deviceData = [];
|
const deviceData = [];
|
||||||
|
|
||||||
@ -132,6 +139,11 @@ async function fetchData() {
|
|||||||
hour: "HH:mm",
|
hour: "HH:mm",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
adapters: {
|
||||||
|
date: {
|
||||||
|
zone: "Europe/Copenhagen",
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -76,6 +76,9 @@ table .temperature {
|
|||||||
table tr:not(:last-child) .temperature {
|
table tr:not(:last-child) .temperature {
|
||||||
border-bottom-color: white;
|
border-bottom-color: white;
|
||||||
}
|
}
|
||||||
|
td {
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
.tempHigh {
|
.tempHigh {
|
||||||
background-color: #ff0000;
|
background-color: #ff0000;
|
||||||
|
Loading…
Reference in New Issue
Block a user