The sunrise equation as follows can be used to derive the time of sunrise and sunset for any
solar declination and latitude in terms of local solar time when sunrise and sunset occur:
cos tan tan w? ? ? ? ? ?
is the hour angle at either sunrise (when negative value is taken) or sunset (when positive value
is the latitude of the observer on the Earth;
is the sun declination.
Theory of the Equation
The Earth rotates at an angular velocity of 15°/hour. Therefore, the expression
w hour ( /15 ) ? ? ?
gives the interval of time before and after local solar noon that sunrise or
sunset will occur.
The sign convention is typically that the observer’s latitude
is 0 at the Equator, positive for
the Northern Hemisphere and negative for the Southern Hemisphere, and the solar
is 0 at the vernal and autumnal equinoxes when the sun is exactly above the
Equator, positive during the Northern Hemisphere summer and negative during the Northern
The expression above is always applicable for latitudes between the Arctic Circle and
Antarctic Circle. North of the Arctic Circle or south of the Antarctic Circle, there is at least
one day of the year with no sunrise or sunset. Formally, there is a sunrise or sunset when
90 90 ? ? ?
? ? ? ? ? ?
during the Northern Hemisphere summer, and when
90 90 ? ? ?
? ? ? ? ? ?
during the Northern Hemisphere winter. Out of these latitudes, it is
either 24-hour daytime or 24-hour night time.
The above equation neglects the influence of atmospheric refraction (which lifts the solar
disc by approximately 0.6° when it is on the horizon) and the non-zero angle subtended by
the solar disc (about 0.5°). The times of the rising and the setting of the upper solar limb as
given in astronomical almanacs correct for this by using the more general equation.
sin sin sin
with the altitude
( ) a
of the center of the solar disc set to about ?0.83°.
Complete Calculation of Sunrise and Sunset on Earth
The generalized equation relies on several other variables which need to be calculated
before it can itself be calculated. These equations have the solar-earth constants substituted
with angular constants expressed in degrees.Calculate Current Julian Day
Julian Day (JD) is the continuous count of days since the beginning of the Julian Period and
is used primarily by astronomers. The Julian Day Number (JDN) is the integer assigned to a
whole solar day in the JD count starting from noon Universal Time (UT), with JDN 0
assigned to the day starting at noon on Monday, 1 January 4713 BC. With this date, all
known historical astronomical observations have positive Julian day numbers, so all
calculations are simple additions and subtractions.
JDN is a counter, each day incremented by one. So, if you know value of JD for one date
and the value of JD for another, you can simply subtract one from another and find out the
difference. JD is a fractional number, where whole part corresponds to 12:00 AM, 0.25 is
6:00 PM, 0.5 – 12:00 PM, 0.75 – 6:00 AM, etc. Thus, the Julian date of any instant is the JDN
plus the fraction of a day since the preceding noon in Universal Time.
Programmers usually convert calendar date to JDN and then use additions and subtractions
to process the date before converting it back in sync to calendar date. It is a practice is to
use the number of milliseconds passed since 1 January 2000 as such a counter. For
example, the JDN for the day starting at 12:00 UT on 1 January 2000, was 2451545.
2451545.0 0.0008 date day elapse J ? ? ?
is the number of days since Jan 1st, 2000 12:00.
is the Julian date; 2451545.0 is the equivalent Julian year (astronomy) of Julian days for 2000, 1,
0008 is the fractional Julian Day for leap seconds and terrestrial time.
Note: Another commonly used reference point is at 12.00 UT on 1 January 1970 (Unix Epoch) where
Julian Day is equivalent to 2440588. The Unix Epoch is the starting point created as a universal
reference. The date when the time started for Unix computers, and that timestamp is marked as ‘0’.
Any time since that date is calculated based on the number of seconds elapsed. In simpler words.
The timestamp of any date will be difference in seconds between that date and ‘1st January 1970’ The
time stamp is just an integer which started from number ‘0’ on ‘Midnight 1st January 1970’ and goes
on incrementing by ‘1’ as each second passes.Mean Solar Noon
Solar noon is the moment when the Sun passes a location’s meridian and reaches its
highest position in the sky.
When Is Solar Noon?
In most places on Earth, solar noon does not happen at 12 o’clock. The Earth’s rotation
slowly shifts the meridian experiencing solar noon from east to west. In other words, solar
noon happens a little earlier in locations just east of you and a little later in locations west of
Where’s Sun right now?
Since our clocks are set according to time zones, civil time changes abruptly as you move
from one-time zone to another, usually in 1-hour increments. While this undeniably makes
life easier for us, it does not reflect the even movement of the Earth’s rotation and the
gradual geographical progression of local solar time.
This means that clocks in the eastern part of each time zone show an earlier time at solar
noon than clocks near its western border. Even if time zones were used the way they were
once envisioned—where local time is based on the solar time in the zone’s center, with the
time zone extending 7.5 degrees of longitude to the west and to the east of the center line—
solar noon would occur at 11:30 (11:30 am) at the eastern time zone border and at 12:30
(12:30 pm) at the western border.
msn n ?
msn approximates mean solar time at
expressed as a Julian day with the day fraction.
longitude west (west is negative, east is positive) of the observer on the Earth;
Mean Solar Anomaly
Because we see the Sun from the planet, we see the motion of the planet around the Sun
reflected in the apparent motion of the Sun along the ecliptic, relative to the stars. If the orbit
of the planet were a perfect circle, then the planet as seen from the Sun would move along
its orbit at a fixed speed, and then it would be simple to calculate its position (and the
position of the Sun as seen from the planet). The position that the planet would have relative
to its perihelion if the orbit of the planet were a circle is called the mean anomaly, indicated
in the formulas as
You can calculate the mean solar anomaly of the Earth (measured in degrees) to reasonable
accuracy using the following formula, for a date given as a JDN.
M msn ? ? ? ?357.5291 0.98560028 ?
is the solar mean anomaly used in a few of next equationsEquation of Center
The orbits of the planets are not perfect circles but rather ellipses, so the speed of the planet
in its orbit varies, and therefore the apparent speed of the Sun along the ecliptic also varies
throughout the planet’s year.
The true anomaly is the angular distance of the planet from the perihelion of the planet, as
seen from the Sun. For a circular orbit, the mean anomaly and the true anomaly are the
same. The difference between the true anomaly and the mean anomaly is called the
Equation of Center,
To calculate the Equation of Center or the true anomaly from the mean anomaly, you must
first solve the Equation of Kepler. This equation cannot be solved in general, but you can
find approximations to the solution using the following:
C ?1.9148sin( ) 0.0200sin(2 ) 0.0003sin(3 ) M M M ? ?
is the Equation of the center value needed to calculate Ecliptic Longitude
The ecliptical longitude
(lambda) is the position along the ecliptic, relative to the vernal
To find the position of the Sun in the sky we need to know what the ecliptic longitude
the perihelion of the planet, relative to the ecliptic and vernal equinox (the ascending equinox)
of the planet. The ecliptic of the planet is the plane of the orbit of the planet, which makes an
angle with the orbit (ecliptic) of the Earth (and that angle is called the inclination of the orbit).
The vernal equinox of the planet is the point where the Sun passes from south to north
through the plane of the equator of the planet. We also need to know the obliquity ? of the
equator of the planet compared to the orbit of the planet.
? ? ?M C? ? ? 180 102.9372?
is a value for the argument of perihelion.
The Earth’s obliquity ? is
Note: Earth revolves around the Sun in an elliptical orbit. As a result, Earth’s distance from the Sun
(center-to-center) varies. The perihelion of any orbit of a celestial body about the Sun is the point
where the body comes nearest to the Sun. The value for the “Argument of Perihelion” is not constant,
and changes (very slightly) per day. The difference is very small, but may make an error in sunrise or
sunset of about a minute. The calculation of perihelion is rather complex is beyond the scope of the
assignment.Degrees Minutes Seconds to Decimal Degrees
Latitude measures how far north or south of the equator a place is located. The equator is
situated at 0°, the North Pole at 90° north (or 90°, because a positive latitude implies north),
and the South Pole at 90° south (or –90°). Latitude measurements range from 0° to (+/–) 90°.
Longitude measures how far east or west of the prime meridian a place is located Longitude
measurements range from 0° to (+/–) 180°.
Latitude and longitude readings are conventional represented in Degrees Minutes Seconds
(DMS). You can convert Degrees, Minutes, Seconds for both latitude and longitude to
Decimal Degrees (DD).
How to Convert Degrees Minutes Seconds to Decimal Degrees
First of all let’s take a look at the symbols:
° : degree
‘ : minute
” : second
1 minute is equal to 60 seconds.
1 degree is equal to 1 hour, that is equal to 60 minutes or 3600 seconds.
To calculate decimal degrees, we use the DMS to DD formula below:
DD = degrees + (minutes / 60) + (seconds / 3600)
Latitude (DD) : 1.290270 is equivalent to Latitude (DMS) : 1° 17′ 24.9720” N
Longitude (DD) : 103.851959 is equivalent to Longitude (DMS): 103° 51’ 7.0524” E
Note: For your assignment, your program should read in latitude and longitude in DD. You may obtain
the coordinates for a location from here: https://www.latlong.net/
A time zone is a region of the globe that observes a uniform standard time for legal,
commercial, and social purposes. Time zones tend to follow the boundaries of countries and
their subdivisions because it is convenient for areas in close commercial or other
communication to keep the same time.
The Java TimeZone API is a class that represents time zones, and is helpful when doing
calendar arithmetics across time zones. The java.util.TimeZone API is used in conjunction
with the java.util.Calendar API. Refer to reference source to get a list of Timezone Ids.Coordinated Universal Time (UTC) is the basis for civil time today. This 24-hour time
standard is kept using highly precise atomic clocks combined with the Earth’s rotation.
UTC is the time standard commonly used across the world. The world’s timing centers have
agreed to keep their time scales closely synchronized – or coordinated – therefore the name
Coordinated Universal Time.
Daylight Saving Time
Daylight Saving Time (DST) is the practice of setting the clocks forward 1 hour from
standard time during the summer months, and back again in the fall, to make better use of
Why Use DST
Less than 40% of the countries in the world use DST. Some countries use it to make better
use of the natural daylight in the evenings. The difference in light is most noticeable in the
areas at a certain distance from Earth’s equator.
Many countries in the Northern Hemisphere (north of the equator) use DST in the summer
time, but not all. Daylight Saving Time usually starts in March-April and ends in SeptemberNovember
when the countries return to standard time.
Some studies show that DST could lead to fewer road accidents and injuries by supplying
more daylight during the hours more people use the roads. DST is also used to reduce the
amount of energy needed for artificial lighting during the evening hours.
The sunrise equation as follows can be used to derive the time of sunrise and sunset for any