Replace inaccurate sunrise/sunset calculation with API #9

Closed
opened 2026-02-15 04:56:34 -08:00 by kyle · 0 comments
Owner

Problem: The custom method used a simplified astronomical formula that could be off by 15-30 minutes, especially at Stockholm's high latitude. This affected dark mode switching and the daylight hours bar accuracy.

Solution: Replaced the manual calculation with calls to the sunrise-sunset.org API (free, no key required). The API returns accurate UTC ISO timestamps for any date. Updated both (now fetches today+tomorrow from API) and (now fetches tomorrow from API instead of calculating). Falls back to hardcoded 07:00/16:00 defaults if API is unreachable.

Files changed:

    • Replaced with , made async
**Problem:** The custom method used a simplified astronomical formula that could be off by 15-30 minutes, especially at Stockholm's high latitude. This affected dark mode switching and the daylight hours bar accuracy. **Solution:** Replaced the manual calculation with calls to the sunrise-sunset.org API (free, no key required). The API returns accurate UTC ISO timestamps for any date. Updated both (now fetches today+tomorrow from API) and (now fetches tomorrow from API instead of calculating). Falls back to hardcoded 07:00/16:00 defaults if API is unreachable. **Files changed:** - - Replaced with , made async
kyle closed this issue 2026-02-15 05:05:26 -08:00
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: kyle/SignageHTML#9