From 125cb470e929b246a7e7bd56b5d8bba0c78a306c Mon Sep 17 00:00:00 2001 From: "noa.santo" Date: Tue, 9 Jan 2024 16:21:16 +0100 Subject: [PATCH] fix: test now pass --- .../daylight-percentage-calculator.ts | 4 ++-- .../content/heroes/aurora/weather-easter-egg/sun.tsx | 12 ++++++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/components/content/heroes/aurora/weather-easter-egg/daylight-percentage-calculator.ts b/src/components/content/heroes/aurora/weather-easter-egg/daylight-percentage-calculator.ts index e69d095fc..615e0f403 100644 --- a/src/components/content/heroes/aurora/weather-easter-egg/daylight-percentage-calculator.ts +++ b/src/components/content/heroes/aurora/weather-easter-egg/daylight-percentage-calculator.ts @@ -7,7 +7,7 @@ export const getSunlightPercentage = ( if (totalDaylightMinutes <= 0) { return 20; } - const currentMinutes = time - sunriseTime + 86400000; + const currentMinutes = time - sunriseTime; const sunlightPercentage = (currentMinutes / totalDaylightMinutes) * 100; if (sunlightPercentage < 0) { @@ -29,7 +29,7 @@ export const getNighttimePercentage = ( if (totalNighttimeMinutes <= 0) { return 0; } - const currentMinutes = time - sunsetTime + 86400000; + const currentMinutes = time - sunsetTime; const nighttimePercentage = (currentMinutes / totalNighttimeMinutes) * 100; if (nighttimePercentage < 0) { diff --git a/src/components/content/heroes/aurora/weather-easter-egg/sun.tsx b/src/components/content/heroes/aurora/weather-easter-egg/sun.tsx index fc4a9078f..7a362a160 100644 --- a/src/components/content/heroes/aurora/weather-easter-egg/sun.tsx +++ b/src/components/content/heroes/aurora/weather-easter-egg/sun.tsx @@ -179,18 +179,22 @@ export const Sun = () => { setSunrise(sunriseTime); setSunset(sunsetTime); setTimePercent( - getSunlightPercentage(sunriseTime, sunsetTime, +new Date()), + getSunlightPercentage(sunriseTime, sunsetTime, +new Date() + 86400000), ); setNightTimePercent( - getNighttimePercentage(sunriseTime, sunsetTime, +new Date()), + getNighttimePercentage(sunriseTime, sunsetTime, +new Date() + 86400000), ); }; fetchData(); const interval = setInterval(() => { - setTimePercent(getSunlightPercentage(sunrise, sunset, +new Date())); - setNightTimePercent(getNighttimePercentage(sunrise, sunset, +new Date())); + setTimePercent( + getSunlightPercentage(sunrise, sunset, +new Date() + 86400000), + ); + setNightTimePercent( + getNighttimePercentage(sunrise, sunset, +new Date() + 86400000), + ); }, 10000); return () => {