@@ -774,6 +786,18 @@ var effect = (VANTA.CLOUDS2 || VANTA.CLOUDS)({
document.getElementById('sunset-value').textContent = formatTimeHM(sunsetNext.date);
document.getElementById('sunset-when').textContent = sunsetNext.label ? '· ' + sunsetNext.label : '';
+ // Sun zenith (solar noon) - find next occurrence
+ var sunZenith = sunTimes.solarNoon;
+ var sunZenithWhen = sunZenith > now ? 'heute' : 'morgen';
+ if (sunZenith <= now) {
+ var tomorrow = new Date(now);
+ tomorrow.setDate(tomorrow.getDate() + 1);
+ sunZenith = SunCalc.getTimes(tomorrow, PASSAU_LAT, PASSAU_LON).solarNoon;
+ sunZenithWhen = formatDateLong(tomorrow);
+ }
+ document.getElementById('sun-zenith-value').textContent = formatTimeHM(sunZenith);
+ document.getElementById('sun-zenith-when').textContent = '· ' + sunZenithWhen;
+
// Moon times
var moonTimes = SunCalc.getMoonTimes(now, PASSAU_LAT, PASSAU_LON);
var moonriseNext = getNextEvent(moonTimes.rise, now, PASSAU_LAT, PASSAU_LON, 'moonrise');
@@ -850,6 +874,18 @@ var effect = (VANTA.CLOUDS2 || VANTA.CLOUDS)({
getMoonPhaseText(moonIllum.phase) + ' ' + Math.round(moonIllum.fraction * 100) + '%';
renderMoonPhaseIcon(moonIllum.phase, moonIllum.fraction);
renderRpgMoon(moonIllum.phase, moonIllum.fraction);
+
+ // Moon zenith - cache for 1 hour to save CPU
+ if (!window._moonZenithCache || Date.now() - window._moonZenithCache.time > 3600000) {
+ window._moonZenithCache = {
+ time: Date.now(),
+ zenith: findMoonZenith(now)
+ };
+ }
+ var moonZenith = window._moonZenithCache.zenith;
+ var moonZenithWhen = moonZenith && moonZenith > now ? formatDateLong(moonZenith) : '';
+ document.getElementById('moon-zenith-value').textContent = moonZenith ? formatTimeHM(moonZenith) : '--:--';
+ document.getElementById('moon-zenith-when').textContent = moonZenithWhen ? '· ' + moonZenithWhen : '';
}
var startTime = Date.now();
@@ -972,6 +1008,25 @@ var weatherThemes = {
return (now.getTime() - startOfDay.getTime()) / 86400000;
}
+ function findMoonZenith(now) {
+ // Sample moon altitude every 15 minutes over next 36 hours
+ var maxAlt = -Math.PI;
+ var zenith = null;
+ for (var i = 0; i < 144; i++) {
+ var sample = new Date(now.getTime() + i * 15 * 60 * 1000);
+ var pos = SunCalc.getMoonPosition(sample, PASSAU_LAT, PASSAU_LON);
+ if (pos.altitude > maxAlt) {
+ maxAlt = pos.altitude;
+ zenith = sample;
+ }
+ // Stop early if we found a peak and started rising again
+ if (i > 4 && zenith && pos.altitude < maxAlt - 0.1) {
+ break;
+ }
+ }
+ return zenith;
+ }
+
function updateDebug(t, palette, vantaColors, themeName) {
try {
var now = new Date();