Solar
A small Swift library that calculates sunrise and sunset times, including civil, nautical, and astronomical twilight, entirely on-device from a date and a location, with no network access required.
Solar is a Swift library that calculates sunrise and sunset times for a given date and geographic coordinate, performing the computation locally using an algorithm from the United States Naval Observatory rather than calling a web service. Given just a location, it also defaults to the current date and time.
Besides the official sunrise and sunset moments, it can compute civil, nautical, and astronomical twilight, which differ by how far the sun sits below the horizon, and it provides convenience properties for checking whether a given location and date fall in daytime or nighttime.
It installs through the Swift Package Manager and is distributed under the MIT license.