Alexander Gromnitsky's Blog

Sunrise/Sunset Algo

Latest update:

If you need to implement sunrise/sunset calculations having only a latitude/longitude (& a particular date), look here.

If found that with zenith = 90.79 it gives the same rise/set numbers as googling for "<location> sunrise".

Also be careful with defining your sin/asin et al. that should take degrees & return degrees. For example:

let sin = (d) => Math.sin(d * (Math.PI / 180))
let asin = (d) => Math.asin(d) * (180/Math.PI)

I had to do the same while reviving an old timezone viewer tktz to force it to work again on Fedora 23. Of course I forgot that asin() returns radians & was scratching my head over why I was getting phoney baloney numbers.


Tags: ойті
Authors: ag