Function: lunar-phase-list

lunar-phase-list is a byte-compiled function defined in lunar.el.gz.

Signature

(lunar-phase-list MONTH YEAR &optional N)

Documentation

List of lunar phases for Gregorian MONTH, YEAR and next N months.

If N is omitted or nil, return lunar phases for three months starting with MONTH, YEAR.

Source Code

;; Defined in /usr/src/emacs/lisp/calendar/lunar.el.gz
(defun lunar-phase-list (month year &optional N)
  "List of lunar phases for Gregorian MONTH, YEAR and next N months.
If N is omitted or nil, return lunar phases for three months starting
with MONTH, YEAR."
  (unless (integerp N) (setq N 2))
  (let* ((index (lunar-index (list month 1 year)))
         (new-moon (lunar-phase index))
         (end-date (let ((end-month month)
                         (end-year year))
                     (calendar-increment-month end-month end-year (1+ N))
                     (list (list end-month 1 end-year))))
         ;; Alternative for start-date:
;;;         (calendar-gregorian-from-absolute
;;;          (1- (calendar-absolute-from-gregorian (list month 1 year))))
         (start-date (progn
                       (calendar-increment-month month year -1)
                       (list (list month
                                   (calendar-last-day-of-month month year)
                                   year))))
         list)
    (while (calendar-date-compare new-moon end-date)
      (if (calendar-date-compare start-date new-moon)
          (setq list (append list (list new-moon))))
      (setq index (1+ index)
            new-moon (lunar-phase index)))
    list))