From 9dc247a861be845ff79ce38430ace2591d187975 Mon Sep 17 00:00:00 2001
From: Jakob Stendahl <jakob.stendahl@outlook.com>
Date: Wed, 27 Apr 2022 00:32:41 +0200
Subject: Move all data fetching to a store, add spinner for loading

---
 src/components/PredictedSpaceWeatherThing.svelte | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

(limited to 'src/components/PredictedSpaceWeatherThing.svelte')

diff --git a/src/components/PredictedSpaceWeatherThing.svelte b/src/components/PredictedSpaceWeatherThing.svelte
index 5c4cb5b..7c343e9 100644
--- a/src/components/PredictedSpaceWeatherThing.svelte
+++ b/src/components/PredictedSpaceWeatherThing.svelte
@@ -5,10 +5,17 @@
       "July", "August", "September", "October", "November", "December"
     ];
 
+    function zpad(value, n=2) {
+        let r = value;
+        for (let i = 0; i < n - value.length; i++) {
+            r = "0" + r;
+        }
+        return r;
+    }
+
     let kp = prediction["kp"];
-    let dateTime = prediction["time"].split(" ");
-    let date = Number(dateTime[0].split("-")[2]) + ". " + monthNames[Number(dateTime[0].split("-")[1])];
-    let time = dateTime[1].substring(0,5);
+    let date = prediction["time"].getDate()  + ". " + monthNames[prediction["time"].getMonth()];
+    let time = zpad(prediction["time"].getHours().toString()) + ":" + zpad(prediction["time"].getMinutes().toString());
     let temp = prediction["temp"];
     let clouds = prediction["clouds"];
     let hasNOMETData = prediction["hasNOMETData"];
-- 
cgit v1.2.3

