Function: solar-date-next-longitude

solar-date-next-longitude is a byte-compiled function defined in solar.el.gz.

Signature

(solar-date-next-longitude D L)

Documentation

First time after day D when solar longitude is a multiple of L degrees.

D is a Julian day number. L must be an integer divisor of 360. The result is for calendar-location-name, and is in local time
(including any daylight saving rules) expressed in astronomical (Julian)
day numbers. The values of calendar-daylight-savings-starts, calendar-daylight-savings-starts-time, calendar-daylight-savings-ends, calendar-daylight-savings-ends-time, calendar-daylight-time-offset, and calendar-time-zone are used to interpret local time.

Source Code

;; Defined in /usr/src/emacs/lisp/calendar/solar.el.gz
(defun solar-date-next-longitude (d l)
  "First time after day D when solar longitude is a multiple of L degrees.
D is a Julian day number.  L must be an integer divisor of 360.
The result is for `calendar-location-name', and is in local time
\(including any daylight saving rules) expressed in astronomical (Julian)
day numbers.  The values of `calendar-daylight-savings-starts',
`calendar-daylight-savings-starts-time', `calendar-daylight-savings-ends',
`calendar-daylight-savings-ends-time', `calendar-daylight-time-offset',
and `calendar-time-zone' are used to interpret local time."
  (let ((start d)
        (next (mod (* l (1+ (floor (/ (solar-longitude d) l)))) 360))
        (end (+ d (* (/ l 360.0) 400)))
        long)
    ;; Bisection search for nearest minute.
    (while (< 0.00001 (- end start))
      ;; start <= d < end
      ;; start-long <= next < end-long when next != 0
      ;; when next = 0, look for the discontinuity (start-long is near 360
      ;; and end-long is small (less than l)).
      (setq d (/ (+ start end) 2.0)
            long (solar-longitude d))
      (if (or (and (not (zerop next)) (< long next))
              (and (zerop next) (< l long)))
          (setq start d)
        (setq end d)))
    (/ (+ start end) 2.0)))