From f065fa22c23cf66a4f52ec1f108a659264430cae Mon Sep 17 00:00:00 2001 From: Xaloc Date: Tue, 23 Aug 2022 11:25:46 +0200 Subject: [PATCH] Change date/time display for cloud coverage forecast --- index.html | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/index.html b/index.html index dbcd4e9..7727396 100644 --- a/index.html +++ b/index.html @@ -98,7 +98,9 @@ const valTime = await fetch('https://opendata-download-metfcst.smhi.se/api/category/pmp3g/version/2/validtime.json'); const times = await valTime.json(); var time = times.validTime[1].replace(/-/g, "").replace(/:/g, ""); - document.getElementById('clouds').textContent = "Cloud Coverage Forcast for " + times.validTime[1].replace(/T/g, " ").replace(/Z/g, " UTC"); + var textTime = new Date(times.validTime[1]).toLocaleString("en-GB", {dateStyle: "short", timeStyle: "short"}); + var textTimeUTC = new Date(times.validTime[1]).toLocaleTimeString("en-GB", {timeZone: "UTC", timeStyle: "short"}); + document.getElementById('clouds').textContent = "Cloud Coverage Forcast for " + textTime + " (" + textTimeUTC+" UTC)"; const res = await fetch(`https://opendata-download-metfcst.smhi.se/api/category/pmp3g/version/2/geotype/multipoint/validtime/${time}/parameter/tcc_mean/leveltype/hl/level/0/data.json`); const data = await res.json();