From cc30422825a5acf460d026bfe912b327b70dedcf Mon Sep 17 00:00:00 2001 From: =?utf8?q?Ulrich=20M=C3=BCller?= Date: Sun, 12 Feb 2023 20:57:49 +0100 Subject: [PATCH] Fix spurious display of eclipses in Calendar * lisp/calendar/lunar.el (eclipse-check): Don't show an eclipse unless the phase is new moon or full moon. (bug#61460) * test/lisp/calendar/lunar-tests.el (lunar-test-eclipse-check) (lunar-test-phase-list): Update tests. --- lisp/calendar/lunar.el | 4 +++- test/lisp/calendar/lunar-tests.el | 27 +++++++++++++++------------ 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/lisp/calendar/lunar.el b/lisp/calendar/lunar.el index 0db811417af..70681f42c90 100644 --- a/lisp/calendar/lunar.el +++ b/lisp/calendar/lunar.el @@ -161,7 +161,9 @@ remainder mod 4 gives the phase: 0 new moon, 1 first quarter, 2 full moon, (phase-name (cond ((= phase 0) "Solar") ((= phase 2) "Lunar") (t "")))) - (cond ((< moon-lat 2.42600766e-1) + (cond ((string= phase-name "") + "") + ((< moon-lat 2.42600766e-1) (concat "** " phase-name " Eclipse **")) ((< moon-lat 0.37) (concat "** " phase-name " Eclipse possible **")) diff --git a/test/lisp/calendar/lunar-tests.el b/test/lisp/calendar/lunar-tests.el index 0d66403e3b6..baae9282628 100644 --- a/test/lisp/calendar/lunar-tests.el +++ b/test/lisp/calendar/lunar-tests.el @@ -43,21 +43,24 @@ (ert-deftest lunar-test-eclipse-check () (with-lunar-test - (should (equal (eclipse-check 1 1) "** Eclipse **")))) + (should (equal (eclipse-check 10.0 1) "")) + (should (equal (eclipse-check 10.0 2) "** Lunar Eclipse **")))) (ert-deftest lunar-test-phase-list () (with-lunar-test - (should (equal (lunar-phase-list 3 1871) - '(((3 21 1871) "04:03" 0 "") - ((3 29 1871) "06:46" 1 "** Eclipse **") - ((4 5 1871) "14:20" 2 "") - ((4 12 1871) "05:57" 3 "** Eclipse possible **") - ((4 19 1871) "19:06" 0 "") - ((4 27 1871) "23:49" 1 "") - ((5 4 1871) "22:57" 2 "") - ((5 11 1871) "14:29" 3 "") - ((5 19 1871) "10:46" 0 "") - ((5 27 1871) "13:02" 1 "")))))) + (should (equal (lunar-phase-list 9 2023) + '(((9 6 2023) "22:27" 3 "") + ((9 15 2023) "01:40" 0 "") + ((9 22 2023) "19:33" 1 "") + ((9 29 2023) "09:54" 2 "** Lunar Eclipse possible **") + ((10 6 2023) "13:53" 3 "") + ((10 14 2023) "17:55" 0 "** Solar Eclipse **") + ((10 22 2023) "03:30" 1 "") + ((10 28 2023) "20:20" 2 "** Lunar Eclipse **") + ((11 5 2023) "08:42" 3 "") + ((11 13 2023) "09:27" 0 "") + ((11 20 2023) "10:51" 1 "") + ((11 27 2023) "09:13" 2 "")))))) (ert-deftest lunar-test-new-moon-time () (with-lunar-test -- 2.39.2