Sun and Moon Info

Generally, we can see the sun and moon every day, but if you look closely, you will find that in some regions and on special dates, the sun or moon does not appear. This documentation will introduce the special case about Sun and Moon.

Note: You need to adapt sunrise/set or moonrise/set to return null to avoid program failure.

Sunrise and sunset

Sunrise is the moment when the upper rim of the Sun appears on the horizon in the morning. The sunrise time is the moment at which the upper limb of the Sun appears tangent to the horizon.

Sunset is the daily disappearance of the Sun below the horizon due to Earth’s rotation. The sunset time is defined in astronomy as the moment when the upper limb of the Sun disappears below the horizon.

For people living in high latitudes(60+ degrees) areas, sunrise and sunset times are seen differently than in other areas. Sunrise and sunset data may not exist at high latitudes areas due to polar days and nights.

For example, in the city of Longyearbyen, between November and March each year, there is a polar night period, so sunrise and sunset will be null.

And at the beginning and end of polar day or night, sunrise or sunset will be null.

Moonrise and moonset

Moonrise and moonset are more complex and variable, and we have listed some common scenarios.

Why does the moon rise in the morning?

Why does the moon sometimes rise at 9:00 a.m.? Doesn’t the moon only appear at night? You have made a mistake in your data…

Actually, the moon does not appear only at night.

The rotation period of the Moon is about 29.53 days, so for the Earth, the Moon moves every day at an angle of:

 360° / 29.53 days ≈ 12.2°

This results the Earth must move 12.2° after completing one rotation for the Moon to be visible. And how long does it take for the Earth to move 12.2°? We know that the Earth’s rotation period is about 24 hours, which means that we move 360° / 24 hours = 15° per hour, so obviously the Earth moves 12.2° needs:

12.2° / 15° * 60 minutes ≈ 48.8 minutes

This means that each day’s moonrise is delayed by about 50 minutes compared to the previous day.

So if you see the moon rise at 9 pm, then in about 15 days, you will find the moon rising at 9 am. Generally speaking, around the new moon, the moon appears almost only during the day, while around the full moon, the moon is there all night long.

Note: The above calculations and data are for example only and are not rigorous. In practice, the Moon rises 30 to 70 minutes later each day/night than the day/night before.

Why is there a Moon all day long?

Unlike most satellites of other planets, the Moon’s orbital plane is closer to the ecliptic plane than to the planet’s equatorial plane, you can understand that the Moon is tilted to rotate around the Earth, so at high latitude areas, there is at least one day in each month that the Moon is not visible at all, and at least one day that the Moon appears throughout the day. In this case, moonrise and moonset will be null.

Earth and moon orbits Earth and moon orbits(original image Wikimedia

Only moonrise or moonset

Remember we said above that every day the moonrise is 50 minutes later than the previous day? So when the moonrise on a given day at 23:10-23:59, then the next moonrise is delayed until 00:00-00:49 on the third day. Typically, each month has one day with only a moonrise and one day with only a moonset, and it usually occurs around when the moon phase is first quarter and last quarter.

Moonrise and moonset table for Beijing Moonrise and moonset table for Beijing in 2022. Blank spaces in the table indicate that a rising or a setting did not occur during that 24 hr interval.

Moon phase

Moon phase(or Lunar phase) is the shape of the Moon’s directly sunlit portion, which can be expressed quantitatively using areas or angles, or described qualitatively using the terminology of the 4 major phases: new moon, first quarter, full moon, last quarter and 4 minor phases: waxing crescent, waxing gibbous, waning gibbous, and waning crescent.

Moon phase This image represents the relative positions of the Sun, Earth, and Moon for different moon phase, at this time the observer is located in the northern hemisphere, if the observer is located in the southern hemisphere, the shape of the moon phase seen is inverted from left to right.(original image Wikimedia by Orion 8

The table below shows examples for moon phases.

Note: The shape of the moon phase as viewed in the northern and southern hemispheres is inverted from left to right, but the name is the same. The data in moonPhase.icon is already adapted. For example, when it is in waxing crescent, moonPhase.icon = 801 for the northern hemisphere and moonPhase.icon = 807 for the southern hemisphere.

Moon phase Northern Hemisphere Visibility Southern Hemisphere Visibility Avg. Moonrise Avg. Moonset Northern Hemisphere Illustration Southern Hemisphere Illustration
New Moon Invisible Invisible 06:00 18:00
Waxing crescent Right side 1–49% Left side 1–49% 09:00 21:00
First quarter Right side 50% Left side 50% 12:00 00:00
Waxing gibbous Right side 51–99% Left side 51–99% 15:00 03:00
Full Moon 100% 100% 18:00 06:00
Waning gibbous Left side 99–51% Right side 99–51% 21:00 09:00
Last quarter Left side 50% Right side 50% 00:00 12:00
Waning crescent Left side 49–1% Right side 49–1% 03:00 15:00

Learn more:

  • The video in this article represents the hourly changes in the moon phase and the Moon’s position relative to Earth in 2022: Moon Phase and Libration, 2022
  • This video provides an illustration of how the Moon passes through its phases — a product of its orbit, which allows different parts of its surface to be illuminated by the Sun over the course of a month. The camera is locked to the Moon as the Earth rapidly rotates in the foreground: The Moon’s Phases as Seen from Space