Function: solar-sunrise-and-sunset
solar-sunrise-and-sunset is a byte-compiled function defined in
solar.el.gz.
Signature
(solar-sunrise-and-sunset TIME LATITUDE LONGITUDE HEIGHT)
Documentation
Sunrise, sunset and length of day.
Parameters are the midday TIME and the LATITUDE, LONGITUDE of the location.
TIME is a pair with the first component being the number of Julian centuries
elapsed at 0 Universal Time, and the second component counting Universal Time
hours. For instance, the pair corresponding to November 28, 1995 at 16 UT is
(-0.040945 16), -0.040945 being the number of Julian centuries elapsed between
Jan 1, 2000 at 12 UT and November 28, 1995 at 0 UT.
HEIGHT is the angle the center of the sun has over the horizon for the contact we are trying to find. For sunrise and sunset, it is usually -0.61 degrees, accounting for the edge of the sun being on the horizon.
Coordinates are included because this function is called with latitude=1 degrees to find out if polar regions have 24 hours of sun or only night.
Source Code
;; Defined in /usr/src/emacs/lisp/calendar/solar.el.gz
(defun solar-sunrise-and-sunset (time latitude longitude height)
"Sunrise, sunset and length of day.
Parameters are the midday TIME and the LATITUDE, LONGITUDE of the location.
TIME is a pair with the first component being the number of Julian centuries
elapsed at 0 Universal Time, and the second component counting Universal Time
hours. For instance, the pair corresponding to November 28, 1995 at 16 UT is
\(-0.040945 16), -0.040945 being the number of Julian centuries elapsed between
Jan 1, 2000 at 12 UT and November 28, 1995 at 0 UT.
HEIGHT is the angle the center of the sun has over the horizon for the contact
we are trying to find. For sunrise and sunset, it is usually -0.61 degrees,
accounting for the edge of the sun being on the horizon.
Coordinates are included because this function is called with latitude=1
degrees to find out if polar regions have 24 hours of sun or only night."
(let ((rise-time (solar-moment -1 latitude longitude time height))
(set-time (solar-moment 1 latitude longitude time height))
day-length)
(if (not (and rise-time set-time))
(if (or (and (> latitude 0)
solar-northern-spring-or-summer-season)
(and (< latitude 0)
(not solar-northern-spring-or-summer-season)))
(setq day-length 24)
(setq day-length 0))
(setq day-length (- set-time rise-time)))
(list (if rise-time (+ rise-time (/ calendar-time-zone 60.0)) nil)
(if set-time (+ set-time (/ calendar-time-zone 60.0)) nil)
day-length)))