0

I tried to record the sunrise and sunset info to the diary

#+begin_src emacs-lisp :tangle yes
(sunrise-sunset)
;;(lunar-phases)
#+end_src

#+RESULTS:
: Sunrise 6:57am (CST), sunset 5:00pm (CST) at 40.0N, 116.3E (10:03 hrs daylight)

sunrise-sunset worked as expected,

But to lunar-phases

#+begin_src emacs-lisp :tangle yes
;;(sunrise-sunset)
(lunar-phases)
#+end_src

#+RESULTS:
: Computing phases of the moon...done

How could get the lunar phases as it print to the echo area?

1

In the following example, the month has been hard-coded to be the 11th month of the year (i.e., November), and the year has been hard-coded to be the year 2019.

[How did I come up with this example? I typed M-x find-function RET lunar-phases RET; and, then I placed my cursor on calendar-lunar-phases and repeated the find-function; and, then I extracted the guts of that latter function and came up with the examples below based upon the extracted code.]

(let ((month 11)
      (year 2019))
  (require 'lunar)
  (mapcar
    (lambda (x)
      (format "%s: %s %s" (calendar-date-string (car x))
                          (lunar-phase-name (nth 2 x))
                          (cadr x)))
    (lunar-phase-list month year)))

For a pretty formatted return value, use ....

(let ((month 11)
      (year 2019))
  (require 'lunar)
  (mapconcat
     (lambda (x)
       (format "%s: %s %s" (calendar-date-string (car x))
                           (lunar-phase-name (nth 2 x))
                           (cadr x)))
     (lunar-phase-list month year)
     "\n"))

Which gives us a return value as follows:

Monday, November 4, 2019: First Quarter Moon 2:24am (PST)
Tuesday, November 12, 2019: Full Moon 5:34am (PST)
Tuesday, November 19, 2019: Last Quarter Moon 1:17pm (PST)
Tuesday, November 26, 2019: New Moon 7:08am (PST)
Tuesday, December 3, 2019: First Quarter Moon 10:59pm (PST)
Wednesday, December 11, 2019: Full Moon 9:11pm (PST)
Wednesday, December 18, 2019: Last Quarter Moon 9:03pm (PST)
Wednesday, December 25, 2019: New Moon 9:16pm (PST)
Thursday, January 2, 2020: First Quarter Moon 8:47pm (PST)
Friday, January 10, 2020: Full Moon 11:20am (PST)
Friday, January 17, 2020: Last Quarter Moon 5:04am (PST)
Friday, January 24, 2020: New Moon 1:44pm (PST)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.