emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master b37cb465fe0: ; Adjust limit for eclipse in calendar; rename a fun


From: Ulrich Müller
Subject: master b37cb465fe0: ; Adjust limit for eclipse in calendar; rename a function
Date: Fri, 17 Feb 2023 16:36:32 -0500 (EST)

branch: master
commit b37cb465fe03f115c46862f20fb5852e67999c59
Author: Ulrich Müller <ulm@gentoo.org>
Commit: Ulrich Müller <ulm@gentoo.org>

    ; Adjust limit for eclipse in calendar; rename a function
    
    * lisp/calendar/lunar.el (lunar-check-for-eclipse): Renamed from
    'eclipse-check'; thanks to Michael Heerdegen for the suggestion.
    Add missing documentation string.  Slightly adjust the upper limit
    for the distance from the node.  (bug#61460)
    * test/lisp/calendar/lunar-tests.el
    (lunar-test-check-for-eclipse): Update accordingly.
---
 lisp/calendar/lunar.el            | 23 +++++++++++++----------
 test/lisp/calendar/lunar-tests.el |  6 +++---
 2 files changed, 16 insertions(+), 13 deletions(-)

diff --git a/lisp/calendar/lunar.el b/lisp/calendar/lunar.el
index 1f827ca34b0..4f8f34d954f 100644
--- a/lisp/calendar/lunar.el
+++ b/lisp/calendar/lunar.el
@@ -94,7 +94,7 @@ remainder mod 4 gives the phase: 0 new moon, 1 first quarter, 
2 full moon,
                        (* -0.0016528 time time)
                        (* -0.00000239 time time time))
                     360.0))
-        (eclipse (eclipse-check moon-lat phase))
+         (eclipse (lunar-check-for-eclipse moon-lat phase))
          (adjustment
           (if (memq phase '(0 2))
               (+ (* (- 0.1734 (* 0.000393 time))
@@ -154,19 +154,22 @@ remainder mod 4 gives the phase: 0 new moon, 1 first 
quarter, 2 full moon,
 
 ;; from "Astronomy with your Personal Computer", Subroutine Eclipse
 ;; Line 7000 Peter Duffett-Smith Cambridge University Press 1990
-(defun eclipse-check (moon-lat phase)
+(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)))
-         (phase-name (cond ((= phase 0) "Solar")
-                           ((= phase 2) "Lunar")
-                           (t ""))))
-    (cond
-     ((string= phase-name "") "")
-     ((< node-dist 13.9) (concat "** " phase-name " Eclipse **"))
-     ((< node-dist 21.2) (concat "** " phase-name " Eclipse possible **"))
-     (t ""))))
+         (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.")
diff --git a/test/lisp/calendar/lunar-tests.el 
b/test/lisp/calendar/lunar-tests.el
index baae9282628..e19965d1034 100644
--- a/test/lisp/calendar/lunar-tests.el
+++ b/test/lisp/calendar/lunar-tests.el
@@ -41,10 +41,10 @@
    (should (equal (lunar-phase 1)
                   '((1 8 1900) "05:40" 1 "")))))
 
-(ert-deftest lunar-test-eclipse-check ()
+(ert-deftest lunar-test-check-for-eclipse ()
   (with-lunar-test
-   (should (equal (eclipse-check 10.0 1) ""))
-   (should (equal (eclipse-check 10.0 2) "** Lunar Eclipse **"))))
+   (should (equal (lunar-check-for-eclipse 10.0 1) ""))
+   (should (equal (lunar-check-for-eclipse 10.0 2) "** Lunar Eclipse **"))))
 
 (ert-deftest lunar-test-phase-list ()
   (with-lunar-test



reply via email to

[Prev in Thread] Current Thread [Next in Thread]