# Sunrise and sunset calculator

Sunrise/Sunset calculation for given latitude and longitude or for given city. Source: Almanac for Computers, 1990 published by Nautical Almanac Office United States Naval ObservatoryWashington, DC 20392

This content is licensed under Creative Commons Attribution/Share-Alike License 3.0 (Unported). That means you may freely redistribute or modify this content under the same license conditions and must attribute the original author by placing a hyperlink from your site to this work https://planetcalc.com/300/. Also, please do not modify any references to the original work (if any) contained in this content.

Below are calculators for sunrise and sunset. Algorithm is taken from here. Source of algorithm - Almanac for Computers, 1990, published by Nautical Almanac Office, United States Naval Observatory, Washington, DC 20392

This algorithm is said to be correct for the period from 1980 to 2050 and has one-minute accuracy. However, accuracy degrades for places above 60 degrees of either latitude. And you can expect even worse accuracy for places above 80 degrees of latitude.

Also, for high latitudes you can encounter a polar day or polar night. In this case, calculator shows 24 hours or 0 hours daytime respectively.

I also have to say about the zenith angle which is set by "Boundary between day and night" parameter and has a significant impact on the calculation. Zenith is a line directed from a point on the earth's surface vertically upwards and **zenith angle** is an angle between the vertical and the direction to the center of the celestial object.

If the Sun was a point and Earth didn't have any atmosphere then the zenith angle which shows the full sunset would be 90 degrees. But as the Sun is not the point and has its angular diameter and it's light reflected by solid particles in atmosphere, then, to upper edge of the Sun disappear over horizon, it's centre should be a little bit lower than horizon. It's 90 degrees 50 minutes at normal atmospheric conditions. It's "official" sunset angle.

Although, the Sun cannot be seen beyond the horizon it's often quite bright because of atmospheric reflection. The period called twilight starting. **Twilight** can be separated into 3 stages and the end of each of those stages can be used as a sunset point.

The first stage is called **civil twilight**. It's still quite bright to work without artificial lights indoors at this time. End of civil twilight is equal to zenith angle of 96 degrees.

Next stage is **nautical twilight**. It's a time when the horizon line can be seen on the water. End of nautical twilight is equal to 102 of zenith angle.

Last stage is called **astronomical twilight**. It's a time when the Sun is still a light source and prevent the dimmest stars visibility. For the casual observer, there is no difference between this time and night. The end of astronomical twilight is when the Sun is no longer a light source and the zenith angle is 108 degrees.

However, as it turned out, the implementation of the algorithm is not all. The fact is that the algorithm outputs the result in Greenwich time. Obviously, for more convenience it is necessary to convert it into the local time. In an ideal world, the time zone can be obtained by using the value of longitude. In fact, the Earth's spheroid is divided into 24 **spherical lunes** through the meridians, spaced apart for 15 degrees, and the time zone is calculated trivially.

But in the real world it is not so - the political, administrative and geographic boundaries gave it a very funny form to the

time zones, so I had to leave the idea of zone determining by longitude. Instead of this I've added an additional field into the calculator to set an offset from Greenwich time.

And idea struck me - why don't I combine this algorithm with reference book Cities Handbook, which is used for Distance between two cities calculator and create another one - Sunrise and sunset calculator for cities using the date from reference book. It has the coordinate already, you just type in the date and the city and get the local time of sunset and sunrise.

Although, it's necessary to know either its summer or winter time. For example, in New Zealand summer time is from 30 April till the last Sunday of September and in Iraq it's from 1st Friday of April till the last Friday of October. I've used the standard European and Russian rules - from 1st Sunday of March till the last Sunday of October.

So for some cities it can be incorrect for march-April and September-October. By the way, not every country use summer/winter time. For example, it's not needed near the equator as the seasonal changes of sunlight are small. Most of the countries were forced to use it, like with colonies.

Summer/winter time was introduced by Englishman William Willett in 1907. English are famous for inventing fun things like imperial measure system (see Conversion between imperial and metric units of area) or irregular shoe sizes (see Shoe size comparison). And many of European countries used the system to save coal during WWI.

The sunset/sunrise calculator is below (if it lacks your city just sign up and add it into reference) and also there is one for set geographical coordinates (for the right local time you have to offset Greenwich time yourself.

P.S. By many requests (see comments below) I've added apparent noon calculation, i.e. the time of the Sun's highest rise. It's actually not equal to 12:00

## Comments