Documentation
¶
Overview ¶
Package solar provides a thin wrapper around github.com/mstephenholl/go-solar for computing sunrise/sunset and determining whether a given UTC instant is during daytime or nighttime.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type SunTimes ¶
SunTimes holds sunrise and sunset times for a given date and location.
func Calculate ¶
Calculate computes sunrise and sunset UTC times for a given date, latitude, and longitude. Computation is delegated to github.com/mstephenholl/go-solar.
Edge cases:
- Polar night (sun never rises): both Sunrise and Sunset are set to the start of the UTC day; the whole day counts as night.
- Midnight sun (sun never sets): Sunrise is set to the start of the UTC day and Sunset to 23:59:59 UTC; the whole day counts as day.
type TwilightTimes ¶ added in v1.2.2
type TwilightTimes struct {
Dawn time.Time // beginning of morning civil twilight (sun at -6° rising)
Dusk time.Time // end of evening civil twilight (sun at -6° setting)
}
TwilightTimes holds the morning (Dawn) and evening (Dusk) civil twilight boundaries for a given UTC date and location.
func CivilTwilight ¶ added in v1.2.2
func CivilTwilight(date time.Time, latitude, longitude float64) TwilightTimes
CivilTwilight computes the morning-civil-twilight start (Dawn) and evening-civil-twilight end (Dusk) in UTC for the given date and location. These are the EASA "night" boundaries: any time between Dusk and the next day's Dawn is night.
Edge cases: polar night collapses the window to zero width (the entire UTC day is night); midnight sun spans the whole UTC day (the entire day is day).