nathan-osman / rust-sunrise

Crate for calculating sunrise / sunset times
MIT License
11 stars 6 forks source link

Twilight #1

Open DAPYXY opened 3 years ago

DAPYXY commented 3 years ago

Added twilight calculations

To implement this in the library I made the azimuth value a variable. I moved the original code to a new function (time_of_transit) that allowed for this, and then wrapped that function with the sunrise_sunset, civil_twilight etc functions that pass the respective azimuth values for civil, nautical and astronomical twilight to the equation. This preserves the functionality of the original code, while enhancing it with the option to calculate twilight. A slight change to the azimuth value for sunrise/sunset to align with the wiki article was made (90° 50' vs 90.8034°), resulting in a 1 second change in the prime_meridian test.

https://en.wikipedia.org/wiki/Sunrise_equation#Generalized_equation

Forked from mklein994 who updated to 2018 syntax