From 10a64339203a8d1148091136dda85e2924db9a2e Mon Sep 17 00:00:00 2001 From: salanileo Date: Mon, 17 Jun 2024 02:40:37 +0200 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=94=A7=20Fixed=20maps=20clock?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/lib/mapData.js | 13 +++++++++++++ src/lib/maps/satellite.svelte | 3 +++ 2 files changed, 16 insertions(+) diff --git a/src/lib/mapData.js b/src/lib/mapData.js index bf41d91..1dfe65f 100644 --- a/src/lib/mapData.js +++ b/src/lib/mapData.js @@ -3,6 +3,7 @@ let overlayItaly = "https://maptiler.infoplaza.io/api/maps/Border/static/11.69,4 let overlayEurope = "https://maptiler.infoplaza.io/api/maps/Border/static/8.24,49.41,4.2/1560x1560.png?attribution=false"; let mese = new Date().getUTCMonth() + 1; let giorno = new Date().getUTCDate(); +let ieri = giorno - 1 let anno = new Date().getFullYear(); var offset = new Date().getTimezoneOffset() / 60; var minuti = new Date().getMinutes() @@ -56,6 +57,18 @@ function getUrl(mapStyle, region, i, ora) { } else if (region == "europe") { zone = "/5/8/14/14/20"; } + console.log(time.substring(0, 2), giorno, ieri) + if (parseInt(time.substring(0, 2)) >= 20 && parseInt(time.substring(0, 2)) < 24) { + if (giorno - 1 == ieri) { + giorno = giorno - 1 + } + } else if (parseInt(time.substring(0, 2)) >= 24) { + if (giorno = ieri ){ + giorno = giorno + 1 + } + time = `0${(time.substring(0, 2)-24)*-1}${time.substring(2)}` + console.log(time) + } let url = base + diff --git a/src/lib/maps/satellite.svelte b/src/lib/maps/satellite.svelte index e7687fe..6718cf7 100644 --- a/src/lib/maps/satellite.svelte +++ b/src/lib/maps/satellite.svelte @@ -24,6 +24,9 @@ function getUrls(type: string, region: string): void { for (let i = 0; i <= stepNum; i++) { + if (ora < 0) { + ora = 24 + ora; + } if (minutes[sourceIndex] === "00") { ora++; } From 9fdf5676e5c784f62e512820316c9cdbb38359a1 Mon Sep 17 00:00:00 2001 From: salanileo Date: Mon, 17 Jun 2024 02:43:27 +0200 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=94=A7=20Fixed=20for=20the=20other=20?= =?UTF-8?q?two=20maps?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/lib/maps/radar.svelte | 12 ++++++++---- src/lib/maps/satelliteEurope.svelte | 12 ++++++++---- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/lib/maps/radar.svelte b/src/lib/maps/radar.svelte index e71517b..0a4b295 100644 --- a/src/lib/maps/radar.svelte +++ b/src/lib/maps/radar.svelte @@ -14,6 +14,7 @@ let playpause = true; let value = "0"; let sourceIndex = 0; + let y = sourceIndex; let source: string = ""; let sourceTime: string = ""; let sources: Array<{ url: string; time: string }> = []; @@ -22,6 +23,9 @@ getUrls("radarsatellite-europe", "italy"); function getUrls(type: string, region: string): void { for (let i = 0; i <= stepNum - 3; i++) { + if (ora < 0) { + ora = 24 + ora; + } if (minutes[sourceIndex] === "00") { ora++; } @@ -31,7 +35,6 @@ if (sourceIndex >= minutes.length) { sourceIndex -= minutes.length; } - const url = getUrl(type, region, sourceIndex, ora); sources.push({ url: url["url"], time: `${ora}${minutes[sourceIndex]}` }); sourceIndex++; @@ -51,8 +54,11 @@ stopLoop(); const { url, time } = sources[sourceIndex]; source = url; - const hours = time.substring(0, 2); + let hours = time.substring(0, 2); const minutes = time.substring(2, 4); + if (parseInt(hours) + offset >= 24) { + hours = String(parseInt(hours) - 24); + } sourceTime = `${parseInt(hours, 10) + offset}:${minutes}`; } } @@ -76,8 +82,6 @@ } } - let y = 0; - const loopFunction = (): void => { if (showmap) { if (y >= sources.length) { diff --git a/src/lib/maps/satelliteEurope.svelte b/src/lib/maps/satelliteEurope.svelte index 922e6d9..c1b088e 100644 --- a/src/lib/maps/satelliteEurope.svelte +++ b/src/lib/maps/satelliteEurope.svelte @@ -14,6 +14,7 @@ let playpause = true; let value = "0"; let sourceIndex = 0; + let y = sourceIndex; let source: string = ""; let sourceTime: string = ""; let sources: Array<{ url: string; time: string }> = []; @@ -23,6 +24,9 @@ function getUrls(type: string, region: string): void { for (let i = 0; i <= stepNum; i++) { + if (ora < 0) { + ora = 24 + ora; + } if (minutes[sourceIndex] === "00") { ora++; } @@ -32,7 +36,6 @@ if (sourceIndex >= minutes.length) { sourceIndex -= minutes.length; } - const url = getUrl(type, region, sourceIndex, ora); sources.push({ url: url["url"], time: `${ora}${minutes[sourceIndex]}` }); sourceIndex++; @@ -52,8 +55,11 @@ stopLoop(); const { url, time } = sources[sourceIndex]; source = url; - const hours = time.substring(0, 2); + let hours = time.substring(0, 2); const minutes = time.substring(2, 4); + if (parseInt(hours) + offset >= 24) { + hours = String(parseInt(hours) - 24); + } sourceTime = `${parseInt(hours, 10) + offset}:${minutes}`; } } @@ -77,8 +83,6 @@ } } - let y = 0; - const loopFunction = (): void => { if (showmap) { if (y >= sources.length) {