KHolidays::SunEvents Class
class KHolidays::SunEventsThe SunEvents type provides dates for solar events, for example sunset or sunrise. More...
Header: | #include <KHolidays/SunEvents> |
CMake: | find_package(KF6 REQUIRED COMPONENTS Holidays) target_link_libraries(mytarget PRIVATE KF6::Holidays) |
Since: | 6.15 |
Public Functions
SunEvents(const QDateTime &dateTime, double latitude, double longitude) | |
SunEvents(const KHolidays::SunEvents &other) | |
~SunEvents() | |
QDateTime | astronomicalDawn() const |
QDateTime | astronomicalDusk() const |
QDateTime | civilDawn() const |
QDateTime | civilDusk() const |
bool | isPolarDay() const |
bool | isPolarNight() const |
bool | isPolarTwilight() const |
QDateTime | nauticalDawn() const |
QDateTime | nauticalDusk() const |
QDateTime | solarNoon() const |
QDateTime | sunrise() const |
QDateTime | sunset() const |
KHolidays::SunEvents & | operator=(const KHolidays::SunEvents &other) |
Detailed Description
The SunEvents type allows you to find dates for solar events at the specified location and date, for example sunset or sunrise. It can also be used to determine whether midnight sun or polar night can be observed for the given time and location.
The following example shows how to use the SunEvents type to determine sunrise and sunset times in Kyiv:
const SunEvents sunEvents(QDateTime::currentDateTime(), 50.45, 30.52); qDebug() << "Sunrise at:" << sunEvents.sunrise().toUTC(); qDebug() << "Sunset at:" << sunEvents.sunset().toUTC();
Note: Due to various approximations, the provided event times are not suitable for the scientific purposes. However, they are good enough for other purposes where accuracy is not critical, for example adjusting the screen color temperature depending on the elevation of the sun.
Member Function Documentation
SunEvents::SunEvents(const QDateTime &dateTime, double latitude, double longitude)
Constructs the SunEvents with the specified dateTime, latitude, and longitude.
The dateTime is used to find the closest solar noon. The times of solar events are provided relative to the closest solar noon.
The latitude is specified in decimal degrees between -90° and 90° inclusive. If the given latitude is outside the valid range, it will be clamped to fit into the [-90, 90] range.
The longitude is specified in decimal degrees between -180° and 180° inclusive. If the given longitude is outside the valid range, it will be clamped to fit into the [-180, 180] range.
SunEvents::SunEvents(const KHolidays::SunEvents &other)
Constructs a copy of the other sun events.
[noexcept]
SunEvents::~SunEvents()
Destroys the sun events.
QDateTime SunEvents::astronomicalDawn() const
The date and time of astronomical sunrise when the sun is 18° below the horizon. At extreme latitudes, the sun may not rise during certain days, in which case, this function will return an invalid QDateTime.
Astronomical dawn is that point in time at which the sun starts lightening the sky. Prior to this time, the sky is completely dark.
See also astronomicalDusk().
QDateTime SunEvents::astronomicalDusk() const
The date and time of astronomical sunset when the sun is 18° below the horizon. At extreme latitudes, the sun may not set during certain days, in which case, this function will return an invalid QDateTime.
Astronomical dusk is that point in time at which the sun no longer illuminates the sky.
See also astronomicalDawn().
QDateTime SunEvents::civilDawn() const
The date and time of astronomical sunrise when the sun is 6° below the horizon. At extreme latitudes, the sun may not rise during certain days, in which case, this function will return an invalid QDateTime.
Civil dawn is that point in time at which there is enough of light for most objects to be seen and outdoor activities may begin.
See also civilDusk().
QDateTime SunEvents::civilDusk() const
The date and time of astronomical sunset when the sun is 6° below the horizon. At extreme latitudes, the sun may not set during certain days, in which case, this function will return an invalid QDateTime.
Civil dusk is that point in time at which the light starts to fade but no artificial light is needed for outdoor activities. The sky is often colored red and orange at this time.
See also civilDawn().
bool SunEvents::isPolarDay() const
Returns true
if it is polar day, also known as midnight sun; otherwise returns false
.
Polar day is a natural phenomenon when the sun stays above -0.83° relative to the horizon at all times. Both sunrise/sunset and dawn/dusk times will be invalid for such a day.
See also isPolarNight() and isPolarTwilight().
bool SunEvents::isPolarNight() const
Returns true
if it is polar night; otherwise returns false
.
Polar night is a natural phenomenon when the sun stays below -6° relative to the horizon at all times. Both sunrise/sunset and dawn/dusk times will be invalid for such a day.
See also isPolarDay() and isPolarTwilight().
bool SunEvents::isPolarTwilight() const
Returns true
if it is polar twilight; otherwise returns false
.
Polar twilight is a natural phenomenon when the sun rises at least above -6° relative the horizon during the day, but remains below -0.83° at all times. Sunrise/sunset times will be invalid for such a day, but dawn/dusk times will be available.
See also isPolarDay() and isPolarNight().
QDateTime SunEvents::nauticalDawn() const
The date and time of astronomical sunrise when the sun is 12° below the horizon. At extreme latitudes, the sun may not rise during certain days, in which case, this function will return an invalid QDateTime.
Nautical dawn is that point in time at which the there is just enough of sunlight for objects to be distinguishable.
See also nauticalDusk().
QDateTime SunEvents::nauticalDusk() const
The date and time of astronomical sunset when the sun is 12° below the horizon. At extreme latitudes, the sun may not set during certain days, in which case, this function will return an invalid QDateTime.
Nautical dusk is that point in time at which most stars become visible.
See also nauticalDawn().
QDateTime SunEvents::solarNoon() const
The date and time when the sun is at its highest position in the sky. The provided date and time is always valid.
QDateTime SunEvents::sunrise() const
The date and time of astronomical sunrise when the sun is 0.833° below the horizon. At extreme latitudes, the sun may not rise during certain days, in which case, this function will return an invalid QDateTime.
See also sunset().
QDateTime SunEvents::sunset() const
The date and time of astronomical sunset when the sun is 0.833° below the horizon. At extreme latitudes, the sun may not set during certain days, in which case, this function will return an invalid QDateTime.
See also sunrise().
KHolidays::SunEvents &SunEvents::operator=(const KHolidays::SunEvents &other)
Assigns other to these sun events and returns a reference to these sun events.