Replace inaccurate sunrise/sunset calculation with API #9
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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: