diff --git a/index.html b/index.html
index 7d9e085..66a9309 100644
--- a/index.html
+++ b/index.html
@@ -842,6 +842,22 @@ var effect = (VANTA.CLOUDS2 || VANTA.CLOUDS)({
function updateClockAndEvents() {
var now = new Date();
+ // Calculate real day progress based on sun position
+ // 0% = midnight, 50% = noon, 100% = next midnight
+ var sunTimes = SunCalc.getTimes(now, PASSAU_LAT, PASSAU_LON);
+ var sunrise = sunTimes.sunrise;
+ var sunset = sunTimes.sunset;
+ var realDayProgress;
+ if (now < sunrise) {
+ var prevSunset = new Date(sunset.getTime() - 24 * 3600 * 1000);
+ realDayProgress = (now.getTime() - prevSunset.getTime()) / (sunrise.getTime() - prevSunset.getTime());
+ } else if (now < sunset) {
+ realDayProgress = 0.5 + (now.getTime() - sunrise.getTime()) / (sunset.getTime() - sunrise.getTime()) * 0.5;
+ } else {
+ realDayProgress = 0.5 + (now.getTime() - sunset.getTime()) / (sunrise.getTime() + 24 * 3600 * 1000 - sunset.getTime()) * 0.5;
+ }
+ realDayProgress = Math.max(0, Math.min(1, realDayProgress));
+
// Real-time clock hands and digital
var h = now.getHours();
var m = now.getMinutes();
@@ -1082,12 +1098,12 @@ var weatherThemes = {
return (now.getTime() - startOfDay.getTime()) / 86400000;
}
- function updateDebug(t, palette, vantaColors, themeName) {
+ function updateDebug(t, palette, vantaColors, themeName, realDayProgress) {
var now = new Date();
var hh = now.getHours(), mm = now.getMinutes(), ss = now.getSeconds();
document.getElementById('dbg-time').textContent =
(hh < 10 ? '0' : '') + hh + ':' + (mm < 10 ? '0' : '') + mm + ':' + (ss < 10 ? '0' : '') + ss;
- document.getElementById('dbg-day').textContent = (t * 100).toFixed(1) + '%';
+ document.getElementById('dbg-day').textContent = realDayProgress != null ? (realDayProgress * 100).toFixed(1) + '%' : (t * 100).toFixed(1) + '%';
document.getElementById('dbg-weather').textContent =
currentWeatherCode + ' (' + (weatherThemes[themeName] ? themeName : '?') + ')';
document.getElementById('dbg-theme').textContent = themeName || '-';
@@ -1184,7 +1200,7 @@ var weatherThemes = {
speed: currentThemeSpeed
});
document.body.style.backgroundColor = '#' + ('00000' + c.sky.toString(16)).slice(-6);
- updateDebug(t, null, c, currentWeatherThemeName);
+ updateDebug(t, null, c, currentWeatherThemeName, realDayProgress);
requestAnimationFrame(animate);
}