here:
An object has a declination 0° on the (celestial) equator, +90° at the north pole and −90° at the south pole. The Sun's declination is approximately equal to[2]
where -23.45 is the axial tilt of the earth. N is the number of the days elapsed after the 1 of January that year.
There are also various more complex, but also more precise formulas. For instance, the same source gives the formula
where
is the day angle (fractional year) in radians.
Changes of the declination over year give the raise of seasons.
Given formulas compute the sunrise and sunset times in the vacuum (if it would be in the Moon). For more precise output, refraction in the Earth's atmosphere must also be taken into consideration:
where a is the altitude of the centre of the solar disc in angular units (about 0.83°)