unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#44237: 28.0.50; Incorrect sunrise time for two days around 31st Decemeber 2020
@ 2020-10-26 11:39 Pankaj Jangid
  2020-10-26 18:26 ` bug#44237: 28.0.50; Incorrect sunrise time for two days around 31st December 2020 Mattias Engdegård
  0 siblings, 1 reply; 5+ messages in thread
From: Pankaj Jangid @ 2020-10-26 11:39 UTC (permalink / raw)
  To: 44237


;; My latitude/longitude settings:
;; (setq calendar-latitude 26.9)                ; Jaipur
;; (setq calendar-longitude 75.8)
(setq calendar-latitude [26 52 north])          ; Jaipur
(setq calendar-longitude [75 46 east])
(setq calendar-location-name "Jaipur, India")

;; TZ
(setq calendar-time-zone +330)
(setq calendar-standard-time-zone-name "IST")
(setq calendar-daylight-time-zone-name "IST")

The ‘S’ command is giving incorrect sunrise time on 30th and 31st
December 2020. I have tried to change the latitude and longitude
slightly. With this change this abnormal behaviour shifts to 31st Dec
and 1st Jan 2021. It implies that this behaviour is dependent it latlong
settings.

The incorrect sunrise time on the faulty days is always 6:30am.


In GNU Emacs 28.0.50 (build 10, x86_64-apple-darwin19.6.0, NS appkit-1894.60 Version 10.15.7 (Build 19H2))
 of 2020-10-26 built on mb2.local
Repository revision: a98bb620c4b4f483694239067b258242c5c7316e
Repository branch: master
Windowing system distributor 'Apple', version 10.3.1894
System Description:  Mac OS X 10.15.7

Configured using:
 'configure LDFLAGS=-L/usr/local/opt/ruby/lib
 CPPFLAGS=-I/usr/local/opt/ruby/include
 PKG_CONFIG_PATH=:/usr/local/opt/sqlite/lib/pkgconfig:/usr/local/opt/libxml2/lib/pkgconfig:/usr/local/opt/openssl/lib/pkgconfig:/usr/local/opt/libffi/lib/pkgconfig:/usr/local/opt/ruby/lib/pkgconfig'

Configured features:
JPEG TIFF GIF PNG RSVG DBUS GLIB NOTIFY KQUEUE ACL GNUTLS LIBXML2 ZLIB
TOOLKIT_SCROLL_BARS NS MODULES THREADS JSON PDUMPER LCMS2

Important settings:
  value of $LC_CTYPE: UTF-8
  value of $LANG: en_IN.UTF-8
  locale-coding-system: utf-8-unix

Major mode: Lisp Interaction

Minor modes in effect:
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message rmc puny dired dired-loaddefs
rfc822 mml mml-sec epa derived epg epg-config gnus-util rmail
rmail-loaddefs auth-source cl-seq eieio eieio-core cl-macs
eieio-loaddefs password-cache json map text-property-search time-date
subr-x seq byte-opt gv bytecomp byte-compile cconv mm-decode mm-bodies
mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail
rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils cal-julian
solar cal-dst vc-git diff-mode easy-mmode cl-loaddefs cl-lib diary-lib
diary-loaddefs cal-move cal-menu easymenu calendar cal-loaddefs tooltip
eldoc electric uniquify ediff-hook vc-hooks lisp-float-type mwheel
term/ns-win ns-win ucs-normalize mule-util term/common-win tool-bar dnd
fontset image regexp-opt fringe tabulated-list replace newcomment
text-mode elisp-mode lisp-mode prog-mode register page tab-bar menu-bar
rfn-eshadow isearch timer select scroll-bar mouse jit-lock font-lock
syntax facemenu font-core term/tty-colors frame minibuffer cl-generic
cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao
korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech
european ethiopic indian cyrillic chinese composite charscript charprop
case-table epa-hook jka-cmpr-hook help simple abbrev obarray
cl-preloaded nadvice button loaddefs faces cus-face macroexp files
window text-properties overlay sha1 md5 base64 format env code-pages
mule custom widget hashtable-print-readable backquote threads dbusbind
kqueue cocoa ns lcms2 multi-tty make-network-process emacs)

Memory information:
((conses 16 65436 7989)
 (symbols 48 7861 1)
 (strings 32 21844 2646)
 (string-bytes 1 778953)
 (vectors 16 14269)
 (vector-slots 8 192707 16217)
 (floats 8 350 389)
 (intervals 56 469 285)
 (buffers 992 13))

-- 
Pankaj





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#44237: 28.0.50; Incorrect sunrise time for two days around 31st December 2020
  2020-10-26 11:39 bug#44237: 28.0.50; Incorrect sunrise time for two days around 31st Decemeber 2020 Pankaj Jangid
@ 2020-10-26 18:26 ` Mattias Engdegård
  2020-10-27  3:52   ` Pankaj Jangid
  0 siblings, 1 reply; 5+ messages in thread
From: Mattias Engdegård @ 2020-10-26 18:26 UTC (permalink / raw)
  To: Pankaj Jangid; +Cc: 44237

[-- Attachment #1: Type: text/plain, Size: 46 bytes --]

Thanks for the report! Does this patch help?


[-- Attachment #2: 0001-Fix-sunrise-and-sunset-calculation-bug-44237.patch --]
[-- Type: application/octet-stream, Size: 3569 bytes --]

From 12fad1d89b101662d3c81c92138e8801f6ad7622 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Mattias=20Engdeg=C3=A5rd?= <mattiase@acm.org>
Date: Mon, 26 Oct 2020 18:44:05 +0100
Subject: [PATCH] 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.
---
 lisp/calendar/solar.el            |  4 +--
 test/lisp/calendar/solar-tests.el | 42 +++++++++++++++++++++++++++++++
 2 files changed, 44 insertions(+), 2 deletions(-)
 create mode 100644 test/lisp/calendar/solar-tests.el

diff --git a/lisp/calendar/solar.el b/lisp/calendar/solar.el
index 05bb3164e1..07562f6224 100644
--- a/lisp/calendar/solar.el
+++ b/lisp/calendar/solar.el
@@ -490,8 +490,8 @@ solar-moment
          (utmin (+ ut (* direction 12.0)))
          (utmax ut)     ; the time searched is between utmin and utmax
          ;; utmin and utmax are in hours.
-         (utmoment-old 0.0)             ; rise or set approximation
-         (utmoment 1.0)                 ; rise or set approximation
+         (utmoment-old utmin)           ; rise or set approximation
+         (utmoment utmax)               ; rise or set approximation
          (hut 0)                        ; sun height at utmoment
          (t0 (car time))
          (hmin (cadr (solar-horizontal-coordinates (list t0 utmin)
diff --git a/test/lisp/calendar/solar-tests.el b/test/lisp/calendar/solar-tests.el
new file mode 100644
index 0000000000..441beafe71
--- /dev/null
+++ b/test/lisp/calendar/solar-tests.el
@@ -0,0 +1,42 @@
+;;; solar-tests.el --- tests for solar.el            -*- lexical-binding: t -*-
+
+;; Copyright (C) 2020 Free Software Foundation, Inc.
+
+;; 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/>.
+
+(require 'ert)
+(require 'solar)
+
+(ert-deftest solar-sunrise-sunset ()
+  ;; Bug#44237: wrong sunrise time on Dec 30 and 31, 2020 for Jaipur.
+  (let ((calendar-latitude 26.9)
+        (calendar-longitude 75.8)
+        (calendar-time-zone +330)
+        (calendar-standard-time-zone-name "IST")
+        (calendar-daylight-time-zone-name "IST")
+        (epsilon (/ 60.0)))             ; Minute accuracy is good enough.
+    (let* ((sunrise-sunset (solar-sunrise-sunset '(12 30 2020)))
+           (sunrise (car (nth 0 sunrise-sunset)))
+           (sunset (car (nth 1 sunrise-sunset))))
+      (should (< (abs (- sunrise 7.27)) epsilon))
+      (should (< (abs (- sunset 17.72)) epsilon)))
+    (let* ((sunrise-sunset (solar-sunrise-sunset '(12 31 2020)))
+           (sunrise (car (nth 0 sunrise-sunset)))
+           (sunset (car (nth 1 sunrise-sunset))))
+      (should (< (abs (- sunrise 7.28)) epsilon))
+      (should (< (abs (- sunset 17.72)) epsilon)))))
+
+(provide 'solar-tests)
-- 
2.21.1 (Apple Git-122.3)


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* bug#44237: 28.0.50; Incorrect sunrise time for two days around 31st December 2020
  2020-10-26 18:26 ` bug#44237: 28.0.50; Incorrect sunrise time for two days around 31st December 2020 Mattias Engdegård
@ 2020-10-27  3:52   ` Pankaj Jangid
  2020-10-27 11:36     ` Mattias Engdegård
  0 siblings, 1 reply; 5+ messages in thread
From: Pankaj Jangid @ 2020-10-27  3:52 UTC (permalink / raw)
  To: Mattias Engdegård; +Cc: 44237

Mattias Engdegård <mattiase@acm.org> writes:

> Thanks for the report! Does this patch help?

Yes. This is giving correct results. Thanks for your work.





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#44237: 28.0.50; Incorrect sunrise time for two days around 31st December 2020
  2020-10-27  3:52   ` Pankaj Jangid
@ 2020-10-27 11:36     ` Mattias Engdegård
  2020-10-27 13:04       ` Pankaj Jangid
  0 siblings, 1 reply; 5+ messages in thread
From: Mattias Engdegård @ 2020-10-27 11:36 UTC (permalink / raw)
  To: Pankaj Jangid; +Cc: 44237-done

27 okt. 2020 kl. 04.52 skrev Pankaj Jangid <pankaj@codeisgreat.org>:

> Yes. This is giving correct results. Thanks for your work.

Pleasure all mine -- I got a trip to Jaipur!
Pushed to master.






^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#44237: 28.0.50; Incorrect sunrise time for two days around 31st December 2020
  2020-10-27 11:36     ` Mattias Engdegård
@ 2020-10-27 13:04       ` Pankaj Jangid
  0 siblings, 0 replies; 5+ messages in thread
From: Pankaj Jangid @ 2020-10-27 13:04 UTC (permalink / raw)
  To: Mattias Engdegård; +Cc: 44237-done

Mattias Engdegård <mattiase@acm.org> writes:

> Pleasure all mine -- I got a trip to Jaipur!

You have treat, when you have a trip in real. Do connect for sure.





^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-10-27 13:04 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-26 11:39 bug#44237: 28.0.50; Incorrect sunrise time for two days around 31st Decemeber 2020 Pankaj Jangid
2020-10-26 18:26 ` bug#44237: 28.0.50; Incorrect sunrise time for two days around 31st December 2020 Mattias Engdegård
2020-10-27  3:52   ` Pankaj Jangid
2020-10-27 11:36     ` Mattias Engdegård
2020-10-27 13:04       ` Pankaj Jangid

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).