aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicholas Strauss2020-01-22 15:12:58 +0100
committerLars Ingebrigtsen2020-01-22 15:12:58 +0100
commitf79a92f02a72303b3b79f0696194c68124627748 (patch)
treec304ebe6491a1485ab43a8e305861f44dd2a9a35
parent0c9da50e96108589c1cac5e25a3627c25a484bc9 (diff)
downloademacs-f79a92f02a72303b3b79f0696194c68124627748.tar.gz
emacs-f79a92f02a72303b3b79f0696194c68124627748.zip
Support solar and lunar eclipses in Calendar
* lisp/calendar/lunar.el (eclipse-check): New function to display solar and lunar eclipses (bug#20414). (lunar-phase): Use it. (calendar-lunar-phases): Ditto.
-rw-r--r--lisp/calendar/lunar.el27
1 files changed, 24 insertions, 3 deletions
diff --git a/lisp/calendar/lunar.el b/lisp/calendar/lunar.el
index 616d2b0c4ed..3d5a0a236b4 100644
--- a/lisp/calendar/lunar.el
+++ b/lisp/calendar/lunar.el
@@ -91,6 +91,7 @@ remainder mod 4 gives the phase: 0 new moon, 1 first quarter, 2 full moon,
91 (* -0.0016528 time time) 91 (* -0.0016528 time time)
92 (* -0.00000239 time time time)) 92 (* -0.00000239 time time time))
93 360.0)) 93 360.0))
94 (eclipse (eclipse-check moon-lat phase))
94 (adjustment 95 (adjustment
95 (if (memq phase '(0 2)) 96 (if (memq phase '(0 2))
96 (+ (* (- 0.1734 (* 0.000393 time)) 97 (+ (* (- 0.1734 (* 0.000393 time))
@@ -146,7 +147,26 @@ remainder mod 4 gives the phase: 0 new moon, 1 first quarter, 2 full moon,
146 (time (* 24 (- date (truncate date)))) 147 (time (* 24 (- date (truncate date))))
147 (date (calendar-gregorian-from-absolute (truncate date))) 148 (date (calendar-gregorian-from-absolute (truncate date)))
148 (adj (dst-adjust-time date time))) 149 (adj (dst-adjust-time date time)))
149 (list (car adj) (apply 'solar-time-string (cdr adj)) phase))) 150 (list (car adj) (apply 'solar-time-string (cdr adj)) phase eclipse)))
151
152;; from "Astronomy with your Personal Computer", Subroutine Eclipse
153;; Line 7000 Peter Duffett-Smith Cambridge University Press 1990
154(defun eclipse-check (moon-lat phase)
155 (let* ((moon-lat (* (/ float-pi 180) moon-lat))
156 (moon-lat (abs (- moon-lat (* (floor (/ moon-lat float-pi))
157 float-pi))))
158 (moon-lat (if (> moon-lat 0.37)
159 (- float-pi moon-lat)
160 moon-lat))
161 (phase-name (cond ((= phase 0) "Solar")
162 ((= phase 2) "Lunar")
163 (t ""))))
164 (cond ((< moon-lat 2.42600766e-1)
165 (concat "** " phase-name " Eclipse **"))
166 ((< moon-lat 0.37)
167 (concat "** " phase-name " Eclipse possible **"))
168 (t
169 ""))))
150 170
151(defconst lunar-cycles-per-year 12.3685 ; 365.25/29.530588853 171(defconst lunar-cycles-per-year 12.3685 ; 365.25/29.530588853
152 "Mean number of lunar cycles per 365.25 day year.") 172 "Mean number of lunar cycles per 365.25 day year.")
@@ -222,9 +242,10 @@ use instead of point."
222 (insert 242 (insert
223 (mapconcat 243 (mapconcat
224 (lambda (x) 244 (lambda (x)
225 (format "%s: %s %s" (calendar-date-string (car x)) 245 (format "%s: %s %s %s" (calendar-date-string (car x))
226 (lunar-phase-name (nth 2 x)) 246 (lunar-phase-name (nth 2 x))
227 (cadr x))) 247 (cadr x)
248 (car (last x))))
228 (lunar-phase-list m1 y1) "\n"))) 249 (lunar-phase-list m1 y1) "\n")))
229 (message "Computing phases of the moon...done")))) 250 (message "Computing phases of the moon...done"))))
230 251