diff options
| author | Mattias EngdegÄrd | 2020-10-26 18:44:05 +0100 |
|---|---|---|
| committer | Mattias EngdegÄrd | 2020-10-27 12:33:51 +0100 |
| commit | cde72637dfd6989081ed8b2f26e7187c309780b8 (patch) | |
| tree | 1784cc7c3cb1edacd353276fbe1bf422d0b71a2c /test | |
| parent | f971a612a92eea4c8aab6b002d7998bb0b6f5ca1 (diff) | |
| download | emacs-cde72637dfd6989081ed8b2f26e7187c309780b8.tar.gz emacs-cde72637dfd6989081ed8b2f26e7187c309780b8.zip | |
Fix sunrise and sunset calculation (bug#44237)
* lisp/calendar/solar.el (solar-moment): Use initial values for binary
search that won't end the loop prematurely and yield incorrect
answers.
* test/lisp/calendar/solar-tests.el: New file.
Diffstat (limited to 'test')
| -rw-r--r-- | test/lisp/calendar/solar-tests.el | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/test/lisp/calendar/solar-tests.el b/test/lisp/calendar/solar-tests.el new file mode 100644 index 00000000000..441beafe71c --- /dev/null +++ b/test/lisp/calendar/solar-tests.el | |||
| @@ -0,0 +1,42 @@ | |||
| 1 | ;;; solar-tests.el --- tests for solar.el -*- lexical-binding: t -*- | ||
| 2 | |||
| 3 | ;; Copyright (C) 2020 Free Software Foundation, Inc. | ||
| 4 | |||
| 5 | ;; This file is part of GNU Emacs. | ||
| 6 | |||
| 7 | ;; GNU Emacs is free software: you can redistribute it and/or modify | ||
| 8 | ;; it under the terms of the GNU General Public License as published by | ||
| 9 | ;; the Free Software Foundation, either version 3 of the License, or | ||
| 10 | ;; (at your option) any later version. | ||
| 11 | |||
| 12 | ;; GNU Emacs is distributed in the hope that it will be useful, | ||
| 13 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 15 | ;; GNU General Public License for more details. | ||
| 16 | |||
| 17 | ;; You should have received a copy of the GNU General Public License | ||
| 18 | ;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. | ||
| 19 | |||
| 20 | (require 'ert) | ||
| 21 | (require 'solar) | ||
| 22 | |||
| 23 | (ert-deftest solar-sunrise-sunset () | ||
| 24 | ;; Bug#44237: wrong sunrise time on Dec 30 and 31, 2020 for Jaipur. | ||
| 25 | (let ((calendar-latitude 26.9) | ||
| 26 | (calendar-longitude 75.8) | ||
| 27 | (calendar-time-zone +330) | ||
| 28 | (calendar-standard-time-zone-name "IST") | ||
| 29 | (calendar-daylight-time-zone-name "IST") | ||
| 30 | (epsilon (/ 60.0))) ; Minute accuracy is good enough. | ||
| 31 | (let* ((sunrise-sunset (solar-sunrise-sunset '(12 30 2020))) | ||
| 32 | (sunrise (car (nth 0 sunrise-sunset))) | ||
| 33 | (sunset (car (nth 1 sunrise-sunset)))) | ||
| 34 | (should (< (abs (- sunrise 7.27)) epsilon)) | ||
| 35 | (should (< (abs (- sunset 17.72)) epsilon))) | ||
| 36 | (let* ((sunrise-sunset (solar-sunrise-sunset '(12 31 2020))) | ||
| 37 | (sunrise (car (nth 0 sunrise-sunset))) | ||
| 38 | (sunset (car (nth 1 sunrise-sunset)))) | ||
| 39 | (should (< (abs (- sunrise 7.28)) epsilon)) | ||
| 40 | (should (< (abs (- sunset 17.72)) epsilon))))) | ||
| 41 | |||
| 42 | (provide 'solar-tests) | ||