# 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

Below are calculators for sunrise and sunset. The algorithm is taken from here. Source of the 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, the calculator shows 24 hours or 0 hours daytime respectively.

I also have to say about the zenith angle, which is set by the "Boundary between day and night" parameter and significantly impacts 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 its light reflected by solid particles in the atmosphere, then, to the upper edge of the Sun disappear over the horizon, its center should be a little bit lower than the horizon. It's 90 degrees 50 minutes at normal atmospheric conditions. It's an "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 starts. **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. The end of civil twilight is equal to a zenith angle of 96 degrees.

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

The last stage is called **astronomical twilight**. It's a time when the Sun is still a light source and prevents 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 hilarious form to the

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

And the 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 the reference book. It has the coordinate already; you type in the date and the city and get the local time of sunset and sunrise.

Although, it's necessary to know either its summertime or wintertime. For example, in New Zealand, summertime is from 30 April till the last Sunday of September, and in Iraq, it's from the 1st Friday of April till the last Friday of October. I've used the standard European and Russian rules - from the 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 uses 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.

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

The sunset/sunrise calculator is below (if it lacks your city, sign up and add it into reference). 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

#### Similar calculators

**

**PLANETCALC, Sunrise and sunset calculator

## Comments