Function: solar-sunrise-sunset

solar-sunrise-sunset is a byte-compiled function defined in solar.el.gz.

Signature

(solar-sunrise-sunset DATE)

Documentation

List of *local* times of sunrise, sunset, and daylight on Gregorian DATE.

Corresponding value is nil if there is no sunrise/sunset.

Source Code

;; Defined in /usr/src/emacs/lisp/calendar/solar.el.gz
(defun solar-sunrise-sunset (date)
  "List of *local* times of sunrise, sunset, and daylight on Gregorian DATE.
Corresponding value is nil if there is no sunrise/sunset."
  ;; First, get the exact moment of local noon.
  (let* ((exact-local-noon (solar-exact-local-noon date))
         ;; Get the time from the 2000 epoch.
         (t0 (solar-julian-ut-centuries (car exact-local-noon)))
         ;; Store the sidereal time at Greenwich at midnight of UT time.
         ;; Find if summer or winter slightly above the equator.
         (equator-rise-set
          (progn (setq solar-sidereal-time-greenwich-midnight
                       (solar-sidereal-time t0))
                 (solar-sunrise-and-sunset
                  (list t0 (cadr exact-local-noon))
                  1.0
                  (calendar-longitude) 0)))
         ;; Store the spring/summer information, compute sunrise and
         ;; sunset (two first components of rise-set).  Length of day
         ;; is the third component (it is only the difference between
         ;; sunset and sunrise when there is a sunset and a sunrise)
         (rise-set
          (progn
            (setq solar-northern-spring-or-summer-season
                  (> (nth 2 equator-rise-set) 12))
            (solar-sunrise-and-sunset
             (list t0 (cadr exact-local-noon))
             (calendar-latitude)
             (calendar-longitude) -0.61)))
         (rise-time (car rise-set))
         (adj-rise (if rise-time (dst-adjust-time date rise-time)))
         (set-time (cadr rise-set))
         (adj-set (if set-time (dst-adjust-time date set-time)))
         (length (nth 2 rise-set)))
    (list
     (and rise-time (calendar-date-equal date (car adj-rise)) (cdr adj-rise))
     (and set-time (calendar-date-equal date (car adj-set)) (cdr adj-set))
     (solar-daylight length))))