mirror of
https://git.savannah.gnu.org/git/emacs.git
synced 2024-09-02 01:35:32 +00:00
dc4e6b1329
; Update copyright years in more files64b3777631
; Run set-copyright from admin.el8e1c56ae46
; Add 2024 to copyright years # Conflicts: # doc/misc/modus-themes.org # doc/misc/texinfo.tex # etc/NEWS # etc/refcards/ru-refcard.tex # etc/themes/modus-operandi-theme.el # etc/themes/modus-themes.el # etc/themes/modus-vivendi-theme.el # lib/alloca.in.h # lib/binary-io.h # lib/c-ctype.h # lib/c-strcasecmp.c # lib/c-strncasecmp.c # lib/careadlinkat.c # lib/cloexec.c # lib/close-stream.c # lib/diffseq.h # lib/dup2.c # lib/filemode.h # lib/fpending.c # lib/fpending.h # lib/fsusage.c # lib/getgroups.c # lib/getloadavg.c # lib/gettext.h # lib/gettime.c # lib/gettimeofday.c # lib/group-member.c # lib/malloc.c # lib/md5-stream.c # lib/md5.c # lib/md5.h # lib/memmem.c # lib/memrchr.c # lib/nanosleep.c # lib/save-cwd.h # lib/sha1.c # lib/sig2str.c # lib/stdlib.in.h # lib/strtoimax.c # lib/strtol.c # lib/strtoll.c # lib/time_r.c # lib/xalloc-oversized.h # lisp/auth-source-pass.el # lisp/emacs-lisp/lisp-mnt.el # lisp/emacs-lisp/timer.el # lisp/info-look.el # lisp/jit-lock.el # lisp/loadhist.el # lisp/mail/rmail.el # lisp/net/ntlm.el # lisp/net/webjump.el # lisp/progmodes/asm-mode.el # lisp/progmodes/project.el # lisp/progmodes/sh-script.el # lisp/textmodes/flyspell.el # lisp/textmodes/reftex-toc.el # lisp/textmodes/reftex.el # lisp/textmodes/tex-mode.el # lisp/url/url-gw.el # m4/alloca.m4 # m4/clock_time.m4 # m4/d-type.m4 # m4/dirent_h.m4 # m4/dup2.m4 # m4/euidaccess.m4 # m4/fchmodat.m4 # m4/filemode.m4 # m4/fsusage.m4 # m4/getgroups.m4 # m4/getloadavg.m4 # m4/getrandom.m4 # m4/gettime.m4 # m4/gettimeofday.m4 # m4/gnulib-common.m4 # m4/group-member.m4 # m4/inttypes.m4 # m4/malloc.m4 # m4/manywarnings.m4 # m4/mempcpy.m4 # m4/memrchr.m4 # m4/mkostemp.m4 # m4/mktime.m4 # m4/nproc.m4 # m4/nstrftime.m4 # m4/pathmax.m4 # m4/pipe2.m4 # m4/pselect.m4 # m4/pthread_sigmask.m4 # m4/readlink.m4 # m4/realloc.m4 # m4/sig2str.m4 # m4/ssize_t.m4 # m4/stat-time.m4 # m4/stddef_h.m4 # m4/stdint.m4 # m4/stdio_h.m4 # m4/stdlib_h.m4 # m4/stpcpy.m4 # m4/strnlen.m4 # m4/strtoimax.m4 # m4/strtoll.m4 # m4/time_h.m4 # m4/timegm.m4 # m4/timer_time.m4 # m4/timespec.m4 # m4/unistd_h.m4 # m4/warnings.m4 # nt/configure.bat # nt/preprep.c # test/lisp/register-tests.el
433 lines
19 KiB
EmacsLisp
433 lines
19 KiB
EmacsLisp
;;; lunar.el --- calendar functions for phases of the moon -*- lexical-binding:t -*-
|
|
|
|
;; Copyright (C) 1992-1993, 1995, 1997, 2001-2024 Free Software
|
|
;; Foundation, Inc.
|
|
|
|
;; Author: Edward M. Reingold <reingold@cs.uiuc.edu>
|
|
;; Maintainer: emacs-devel@gnu.org
|
|
;; Keywords: calendar
|
|
;; Human-Keywords: moon, lunar phases, calendar, diary
|
|
;; Package: calendar
|
|
|
|
;; This file is part of GNU Emacs.
|
|
|
|
;; GNU Emacs is free software: you can redistribute it and/or modify
|
|
;; it under the terms of the GNU General Public License as published by
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
;; (at your option) any later version.
|
|
|
|
;; GNU Emacs is distributed in the hope that it will be useful,
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
;; GNU General Public License for more details.
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
|
;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
;;; Commentary:
|
|
|
|
;; See calendar.el.
|
|
|
|
;; Based on ``Astronomical Formulae for Calculators,'' 3rd ed., by Jean Meeus,
|
|
;; Willmann-Bell, Inc., 1985 and ``Astronomical Algorithms'' by Jean Meeus,
|
|
;; Willmann-Bell, Inc., 1991.
|
|
;;
|
|
;; WARNING: The calculations will be accurate only to within a few minutes.
|
|
|
|
;; The author would be delighted to have an astronomically more sophisticated
|
|
;; person rewrite the code for the lunar calculations in this file!
|
|
|
|
;;; Code:
|
|
|
|
(require 'calendar)
|
|
(require 'solar)
|
|
(require 'cal-dst)
|
|
;; calendar-astro-to-absolute and v versa are cal-autoloads.
|
|
;;;(require 'cal-julian)
|
|
|
|
(defcustom lunar-phase-names
|
|
'("New Moon" "First Quarter Moon" "Full Moon" "Last Quarter Moon")
|
|
"List of names for the lunar phases."
|
|
:type '(list
|
|
(string :tag "New Moon")
|
|
(string :tag "First Quarter Moon")
|
|
(string :tag "Full Moon")
|
|
(string :tag "Last Quarter Moon"))
|
|
:group 'calendar
|
|
:version "23.2")
|
|
|
|
(defun lunar-phase (index)
|
|
"Local date and time of lunar phase INDEX.
|
|
Integer below INDEX/4 gives the lunation number, counting from Jan 1, 1900;
|
|
remainder mod 4 gives the phase: 0 new moon, 1 first quarter, 2 full moon,
|
|
3 last quarter. Returns a list (DATE TIME PHASE)."
|
|
(let* ((phase (mod index 4))
|
|
(index (/ index 4.0))
|
|
(time (/ index 1236.85))
|
|
(date (+ (calendar-absolute-from-gregorian '(1 0.5 1900))
|
|
0.75933
|
|
(* 29.53058868 index) ; FIXME 29.530588853?
|
|
(* 0.0001178 time time)
|
|
(* -0.000000155 time time time)
|
|
(* 0.00033
|
|
(solar-sin-degrees (+ 166.56
|
|
(* 132.87 time)
|
|
(* -0.009173 time time))))))
|
|
(sun-anomaly (mod
|
|
(+ 359.2242
|
|
(* 29.105356 index)
|
|
(* -0.0000333 time time)
|
|
(* -0.00000347 time time time))
|
|
360.0))
|
|
(moon-anomaly (mod
|
|
(+ 306.0253
|
|
(* 385.81691806 index)
|
|
(* 0.0107306 time time)
|
|
(* 0.00001236 time time time))
|
|
360.0))
|
|
;; moon-lat is the argument of latitude, which is the angle
|
|
;; of the moon measured from the ascending node of its orbit
|
|
;; (i.e. argument of perigee + true anomaly).
|
|
(moon-lat (mod
|
|
(+ 21.2964
|
|
(* 390.67050646 index)
|
|
(* -0.0016528 time time)
|
|
(* -0.00000239 time time time))
|
|
360.0))
|
|
(eclipse (lunar-check-for-eclipse moon-lat phase))
|
|
(adjustment
|
|
(if (memq phase '(0 2))
|
|
(+ (* (- 0.1734 (* 0.000393 time))
|
|
(solar-sin-degrees sun-anomaly))
|
|
(* 0.0021 (solar-sin-degrees (* 2 sun-anomaly)))
|
|
(* -0.4068 (solar-sin-degrees moon-anomaly))
|
|
(* 0.0161 (solar-sin-degrees (* 2 moon-anomaly)))
|
|
(* -0.0004 (solar-sin-degrees (* 3 moon-anomaly)))
|
|
(* 0.0104 (solar-sin-degrees (* 2 moon-lat)))
|
|
(* -0.0051 (solar-sin-degrees (+ sun-anomaly moon-anomaly)))
|
|
(* -0.0074 (solar-sin-degrees (- sun-anomaly moon-anomaly)))
|
|
(* 0.0004 (solar-sin-degrees (+ (* 2 moon-lat) sun-anomaly)))
|
|
(* -0.0004 (solar-sin-degrees (- (* 2 moon-lat) sun-anomaly)))
|
|
(* -0.0006 (solar-sin-degrees
|
|
(+ (* 2 moon-lat) moon-anomaly)))
|
|
(* 0.0010 (solar-sin-degrees (- (* 2 moon-lat) moon-anomaly)))
|
|
(* 0.0005 (solar-sin-degrees
|
|
(+ (* 2 moon-anomaly) sun-anomaly))))
|
|
(+ (* (- 0.1721 (* 0.0004 time))
|
|
(solar-sin-degrees sun-anomaly))
|
|
(* 0.0021 (solar-sin-degrees (* 2 sun-anomaly)))
|
|
(* -0.6280 (solar-sin-degrees moon-anomaly))
|
|
(* 0.0089 (solar-sin-degrees (* 2 moon-anomaly)))
|
|
(* -0.0004 (solar-sin-degrees (* 3 moon-anomaly)))
|
|
(* 0.0079 (solar-sin-degrees (* 2 moon-lat)))
|
|
(* -0.0119 (solar-sin-degrees (+ sun-anomaly moon-anomaly)))
|
|
(* -0.0047 (solar-sin-degrees (- sun-anomaly moon-anomaly)))
|
|
(* 0.0003 (solar-sin-degrees (+ (* 2 moon-lat) sun-anomaly)))
|
|
(* -0.0004 (solar-sin-degrees (- (* 2 moon-lat) sun-anomaly)))
|
|
(* -0.0006 (solar-sin-degrees (+ (* 2 moon-lat) moon-anomaly)))
|
|
(* 0.0021 (solar-sin-degrees (- (* 2 moon-lat) moon-anomaly)))
|
|
(* 0.0003 (solar-sin-degrees
|
|
(+ (* 2 moon-anomaly) sun-anomaly)))
|
|
(* 0.0004 (solar-sin-degrees
|
|
(- sun-anomaly (* 2 moon-anomaly))))
|
|
(* -0.0003 (solar-sin-degrees
|
|
(+ (* 2 sun-anomaly) moon-anomaly))))))
|
|
(adj (+ 0.0028
|
|
(* -0.0004 (solar-cosine-degrees
|
|
sun-anomaly))
|
|
(* 0.0003 (solar-cosine-degrees
|
|
moon-anomaly))))
|
|
(adjustment (cond ((= phase 1) (+ adjustment adj))
|
|
((= phase 2) (- adjustment adj))
|
|
(t adjustment)))
|
|
(date (+ date adjustment))
|
|
(date (+ date (/ (- calendar-time-zone
|
|
(solar-ephemeris-correction
|
|
(calendar-extract-year
|
|
(calendar-gregorian-from-absolute
|
|
(truncate date)))))
|
|
60.0 24.0)))
|
|
(time (* 24 (- date (truncate date))))
|
|
(date (calendar-gregorian-from-absolute (truncate date)))
|
|
(adj (dst-adjust-time date time)))
|
|
(list (car adj) (apply 'solar-time-string (cdr adj)) phase eclipse)))
|
|
|
|
;; from "Astronomy with your Personal Computer", Subroutine Eclipse
|
|
;; Line 7000 Peter Duffett-Smith Cambridge University Press 1990
|
|
(defun lunar-check-for-eclipse (moon-lat phase)
|
|
"Check if a solar or lunar eclipse can occur for MOON-LAT and PHASE.
|
|
MOON-LAT is the argument of latitude. PHASE is the lunar phase:
|
|
0 new moon, 1 first quarter, 2 full moon, 3 last quarter.
|
|
Return a string describing the eclipse (empty if no eclipse)."
|
|
(let* ((node-dist (mod moon-lat 180))
|
|
;; Absolute angular distance from the ascending or descending
|
|
;; node, whichever is nearer.
|
|
(node-dist (min node-dist (- 180 node-dist)))
|
|
(type (cond ((= phase 0) "Solar")
|
|
((= phase 2) "Lunar"))))
|
|
(cond ((not type) "")
|
|
;; Limits 13.9° and 21.0° from Meeus (1991), page 350.
|
|
((< node-dist 13.9) (concat "** " type " Eclipse **"))
|
|
((< node-dist 21.0) (concat "** " type " Eclipse possible **"))
|
|
(t ""))))
|
|
|
|
(defconst lunar-cycles-per-year 12.3685 ; 365.25/29.530588853
|
|
"Mean number of lunar cycles per 365.25 day year.")
|
|
|
|
;; FIXME new-moon index; use in lunar-phase-list implies always below.
|
|
(defun lunar-index (date)
|
|
"Return the lunar index for Gregorian date DATE.
|
|
This is 4 times the approximate number of new moons since 1 Jan 1900.
|
|
The factor of 4 allows (mod INDEX 4) to represent the four quarters."
|
|
(* 4 (truncate
|
|
(* lunar-cycles-per-year
|
|
;; Years since 1900, as a real.
|
|
(+ (calendar-extract-year date)
|
|
(/ (calendar-day-number date) 366.0)
|
|
-1900)))))
|
|
|
|
(defun lunar-phase-list (month year)
|
|
"List of lunar phases for three months starting with Gregorian MONTH, YEAR."
|
|
(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 3)
|
|
(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))
|
|
|
|
(defun lunar-phase-name (phase)
|
|
"Name of lunar PHASE.
|
|
0 = new moon, 1 = first quarter, 2 = full moon, 3 = last quarter."
|
|
(nth phase lunar-phase-names))
|
|
|
|
(defvar displayed-month) ; from calendar-generate
|
|
(defvar displayed-year)
|
|
|
|
;;;###cal-autoload
|
|
(defun calendar-lunar-phases (&optional event)
|
|
"Create a buffer with the lunar phases for the current calendar window.
|
|
If EVENT is non-nil, it's an event indicating the buffer position to
|
|
use instead of point."
|
|
(interactive (list last-nonmenu-event))
|
|
;; If called from a menu, with the calendar window not selected.
|
|
(with-current-buffer
|
|
(if event (calendar-event-buffer event)
|
|
(current-buffer))
|
|
(message "Computing phases of the moon...")
|
|
(let ((m1 displayed-month)
|
|
(y1 displayed-year)
|
|
(m2 displayed-month)
|
|
(y2 displayed-year))
|
|
(calendar-increment-month m1 y1 -1)
|
|
(calendar-increment-month m2 y2 1)
|
|
(calendar-in-read-only-buffer lunar-phases-buffer
|
|
(calendar-set-mode-line
|
|
(if (= y1 y2)
|
|
(format "Phases of the Moon from %s to %s, %d%%-"
|
|
(calendar-month-name m1) (calendar-month-name m2) y2)
|
|
(format "Phases of the Moon from %s, %d to %s, %d%%-"
|
|
(calendar-month-name m1) y1 (calendar-month-name m2) y2)))
|
|
(insert
|
|
(mapconcat
|
|
(lambda (x)
|
|
(let ((eclipse (nth 3 x)))
|
|
(concat (calendar-date-string (car x)) ": "
|
|
(lunar-phase-name (nth 2 x)) " "
|
|
(cadr x) (unless (string-empty-p eclipse) " ")
|
|
eclipse)))
|
|
(lunar-phase-list m1 y1) "\n")))
|
|
(message "Computing phases of the moon...done"))))
|
|
|
|
;;;###autoload
|
|
(defun lunar-phases (&optional arg)
|
|
"Display the quarters of the moon for last month, this month, and next month.
|
|
If called with an optional prefix argument ARG, prompts for month and year.
|
|
This function is suitable for execution in an init file."
|
|
(interactive "P")
|
|
(with-suppressed-warnings ((lexical date))
|
|
(defvar date))
|
|
(save-excursion
|
|
(let* ((date (if arg (calendar-read-date t)
|
|
(calendar-current-date)))
|
|
(displayed-month (calendar-extract-month date))
|
|
(displayed-year (calendar-extract-year date)))
|
|
(calendar-lunar-phases))))
|
|
|
|
;;;###diary-autoload
|
|
(defun diary-lunar-phases (&optional mark)
|
|
"Moon phases diary entry.
|
|
An optional parameter MARK specifies a face or single-character string to
|
|
use when highlighting the day in the calendar."
|
|
;; This function is designed to be used in sexp diary entries, and
|
|
;; may be present in users' diary files, so suppress the warning
|
|
;; about this prefix-less dynamic variable. It's called from
|
|
;; `diary-list-sexp-entries', which binds the variable.
|
|
(with-suppressed-warnings ((lexical date))
|
|
(defvar date))
|
|
(let* ((index (lunar-index date))
|
|
(phase (lunar-phase index)))
|
|
(while (calendar-date-compare phase (list date))
|
|
(setq index (1+ index)
|
|
phase (lunar-phase index)))
|
|
(and (calendar-date-equal (car phase) date)
|
|
(cons mark
|
|
(let ((eclipse (nth 3 phase)))
|
|
(concat (lunar-phase-name (nth 2 phase)) " "
|
|
(cadr phase)
|
|
(unless (string-empty-p eclipse) " ")
|
|
eclipse))))))
|
|
|
|
;; For the Chinese calendar the calculations for the new moon need to be more
|
|
;; accurate than those above, so we use more terms in the approximation.
|
|
(defun lunar-new-moon-time (k)
|
|
"Astronomical (Julian) day number of K th new moon."
|
|
(let* ((T (/ k 1236.85))
|
|
(T2 (* T T))
|
|
(T3 (* T T T))
|
|
(T4 (* T2 T2))
|
|
(JDE (+ 2451550.09765
|
|
(* 29.530588853 k)
|
|
(* 0.0001337 T2)
|
|
(* -0.000000150 T3)
|
|
(* 0.00000000073 T4)))
|
|
(E (- 1 (* 0.002516 T) (* 0.0000074 T2)))
|
|
(sun-anomaly (+ 2.5534
|
|
(* 29.10535669 k)
|
|
(* -0.0000218 T2)
|
|
(* -0.00000011 T3)))
|
|
(moon-anomaly (+ 201.5643
|
|
(* 385.81693528 k)
|
|
(* 0.0107438 T2)
|
|
(* 0.00001239 T3)
|
|
(* -0.000000058 T4)))
|
|
(moon-argument (+ 160.7108
|
|
(* 390.67050274 k)
|
|
(* -0.0016341 T2)
|
|
(* -0.00000227 T3)
|
|
(* 0.000000011 T4)))
|
|
(omega (+ 124.7746
|
|
(* -1.56375580 k)
|
|
(* 0.0020691 T2)
|
|
(* 0.00000215 T3)))
|
|
(A1 (+ 299.77 (* 0.107408 k) (* -0.009173 T2)))
|
|
(A2 (+ 251.88 (* 0.016321 k)))
|
|
(A3 (+ 251.83 (* 26.641886 k)))
|
|
(A4 (+ 349.42 (* 36.412478 k)))
|
|
(A5 (+ 84.66 (* 18.206239 k)))
|
|
(A6 (+ 141.74 (* 53.303771 k)))
|
|
(A7 (+ 207.14 (* 2.453732 k)))
|
|
(A8 (+ 154.84 (* 7.306860 k)))
|
|
(A9 (+ 34.52 (* 27.261239 k)))
|
|
(A10 (+ 207.19 (* 0.121824 k)))
|
|
(A11 (+ 291.34 (* 1.844379 k)))
|
|
(A12 (+ 161.72 (* 24.198154 k)))
|
|
(A13 (+ 239.56 (* 25.513099 k)))
|
|
(A14 (+ 331.55 (* 3.592518 k)))
|
|
(correction
|
|
(+ (* -0.40720 (solar-sin-degrees moon-anomaly))
|
|
(* 0.17241 E (solar-sin-degrees sun-anomaly))
|
|
(* 0.01608 (solar-sin-degrees (* 2 moon-anomaly)))
|
|
(* 0.01039 (solar-sin-degrees (* 2 moon-argument)))
|
|
(* 0.00739 E (solar-sin-degrees (- moon-anomaly sun-anomaly)))
|
|
(* -0.00514 E (solar-sin-degrees (+ moon-anomaly sun-anomaly)))
|
|
(* 0.00208 E E (solar-sin-degrees (* 2 sun-anomaly)))
|
|
(* -0.00111 (solar-sin-degrees
|
|
(- moon-anomaly (* 2 moon-argument))))
|
|
(* -0.00057 (solar-sin-degrees
|
|
(+ moon-anomaly (* 2 moon-argument))))
|
|
(* 0.00056 E (solar-sin-degrees
|
|
(+ (* 2 moon-anomaly) sun-anomaly)))
|
|
(* -0.00042 (solar-sin-degrees (* 3 moon-anomaly)))
|
|
(* 0.00042 E (solar-sin-degrees
|
|
(+ sun-anomaly (* 2 moon-argument))))
|
|
(* 0.00038 E (solar-sin-degrees
|
|
(- sun-anomaly (* 2 moon-argument))))
|
|
(* -0.00024 E (solar-sin-degrees
|
|
(- (* 2 moon-anomaly) sun-anomaly)))
|
|
(* -0.00017 (solar-sin-degrees omega))
|
|
(* -0.00007 (solar-sin-degrees
|
|
(+ moon-anomaly (* 2 sun-anomaly))))
|
|
(* 0.00004 (solar-sin-degrees
|
|
(- (* 2 moon-anomaly) (* 2 moon-argument))))
|
|
(* 0.00004 (solar-sin-degrees (* 3 sun-anomaly)))
|
|
(* 0.00003 (solar-sin-degrees (+ moon-anomaly sun-anomaly
|
|
(* -2 moon-argument))))
|
|
(* 0.00003 (solar-sin-degrees
|
|
(+ (* 2 moon-anomaly) (* 2 moon-argument))))
|
|
(* -0.00003 (solar-sin-degrees (+ moon-anomaly sun-anomaly
|
|
(* 2 moon-argument))))
|
|
(* 0.00003 (solar-sin-degrees (- moon-anomaly sun-anomaly
|
|
(* -2 moon-argument))))
|
|
(* -0.00002 (solar-sin-degrees (- moon-anomaly sun-anomaly
|
|
(* 2 moon-argument))))
|
|
(* -0.00002 (solar-sin-degrees
|
|
(+ (* 3 moon-anomaly) sun-anomaly)))
|
|
(* 0.00002 (solar-sin-degrees (* 4 moon-anomaly)))))
|
|
(additional
|
|
(+ (* 0.000325 (solar-sin-degrees A1))
|
|
(* 0.000165 (solar-sin-degrees A2))
|
|
(* 0.000164 (solar-sin-degrees A3))
|
|
(* 0.000126 (solar-sin-degrees A4))
|
|
(* 0.000110 (solar-sin-degrees A5))
|
|
(* 0.000062 (solar-sin-degrees A6))
|
|
(* 0.000060 (solar-sin-degrees A7))
|
|
(* 0.000056 (solar-sin-degrees A8))
|
|
(* 0.000047 (solar-sin-degrees A9))
|
|
(* 0.000042 (solar-sin-degrees A10))
|
|
(* 0.000040 (solar-sin-degrees A11))
|
|
(* 0.000037 (solar-sin-degrees A12))
|
|
(* 0.000035 (solar-sin-degrees A13))
|
|
(* 0.000023 (solar-sin-degrees A14))))
|
|
(newJDE (+ JDE correction additional)))
|
|
(+ newJDE
|
|
(- (solar-ephemeris-correction
|
|
(calendar-extract-year
|
|
(calendar-gregorian-from-absolute
|
|
(floor (calendar-astro-to-absolute newJDE))))))
|
|
(/ calendar-time-zone 60.0 24.0))))
|
|
|
|
(defun lunar-new-moon-on-or-after (d)
|
|
"Julian day number of first new moon on or after Julian day number D.
|
|
The fractional part is the time of day.
|
|
|
|
The date and time are local time, including any daylight saving rules,
|
|
as governed by 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'."
|
|
(let* ((date (calendar-gregorian-from-absolute
|
|
(floor (calendar-astro-to-absolute d))))
|
|
(year (+ (calendar-extract-year date)
|
|
(/ (calendar-day-number date) 365.25)))
|
|
(k (floor (* (- year 2000.0) lunar-cycles-per-year)))
|
|
(date (lunar-new-moon-time k))
|
|
(a-date (progn
|
|
(while (< date d)
|
|
(setq k (1+ k)
|
|
date (lunar-new-moon-time k)))
|
|
(calendar-astro-to-absolute date)))
|
|
(time (* 24 (- a-date (truncate a-date))))
|
|
(date (calendar-gregorian-from-absolute (truncate a-date)))
|
|
(adj (dst-adjust-time date time)))
|
|
(calendar-astro-from-absolute
|
|
(+ (calendar-absolute-from-gregorian (car adj))
|
|
(/ (cadr adj) 24.0)))))
|
|
|
|
(provide 'lunar)
|
|
|
|
;;; lunar.el ends here
|