Thank you for a great package @langestefan .
In these dark times I wanted to compute the sunrise and sunset, but I could not find a function for it.
I can do something like this:
using SolarPosition
using Dates
using TimeZones
using Roots
function sunup(date, obs, tz)
sun_fun(t) = solar_position(obs,ZonedDateTime(unix2datetime(t), tz)).elevation
t1 = datetime2unix(DateTime(Date(date)))
t2 = datetime2unix(DateTime(Date(date) + Day(1))) - 12*60*60
s1 = find_zero(sun_fun, (t1,t2))
ZonedDateTime(unix2datetime(s1), tz)
end
sunup("2025-12-25", Observer(55.681461901184896, 12.57570843999704), TimeZone("Europe/Copenhagen", TimeZones.Class(:LEGACY)))
2025-12-25T08:47:01.617+01:00
But it’s a bit convoluted.
Is there an easier way to do it?