From unknown Fri Jun 20 07:19:51 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#36822 <36822@debbugs.gnu.org> To: bug#36822 <36822@debbugs.gnu.org> Subject: Status: 26.2; Calc: calc-julian produces incorrect result Reply-To: bug#36822 <36822@debbugs.gnu.org> Date: Fri, 20 Jun 2025 14:19:51 +0000 retitle 36822 26.2; Calc: calc-julian produces incorrect result reassign 36822 emacs submitter 36822 "Michel Schinz" severity 36822 normal tag 36822 patch confirmed thanks From debbugs-submit-bounces@debbugs.gnu.org Sat Jul 27 12:10:59 2019 Received: (at submit) by debbugs.gnu.org; 27 Jul 2019 16:10:59 +0000 Received: from localhost ([127.0.0.1]:45240 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hrPHe-0001SI-9a for submit@debbugs.gnu.org; Sat, 27 Jul 2019 12:10:59 -0400 Received: from lists.gnu.org ([209.51.188.17]:33223) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hrJwD-0006DD-Sl for submit@debbugs.gnu.org; Sat, 27 Jul 2019 06:28:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51024) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hrJwC-0007F4-AO for bug-gnu-emacs@gnu.org; Sat, 27 Jul 2019 06:28:29 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.1 required=5.0 tests=BAYES_50,HTML_MESSAGE, RCVD_IN_DNSWL_LOW,URIBL_BLOCKED autolearn=disabled version=3.3.2 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hrJwA-0007dd-Gl for bug-gnu-emacs@gnu.org; Sat, 27 Jul 2019 06:28:28 -0400 Received: from wout4-smtp.messagingengine.com ([64.147.123.20]:46309) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hrJwA-0007aS-0B for bug-gnu-emacs@gnu.org; Sat, 27 Jul 2019 06:28:26 -0400 Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.west.internal (Postfix) with ESMTP id 9E8FC475 for ; Sat, 27 Jul 2019 06:28:22 -0400 (EDT) Received: from imap4 ([10.202.2.54]) by compute2.internal (MEProxy); Sat, 27 Jul 2019 06:28:22 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=schi.nz; h= mime-version:message-id:date:from:to:subject:content-type; s= fm3; bh=kd0CSb157Xk/IONdrE69QkPk9THy98cRQQb48eXnGdk=; b=vuguiYKT jjp0WQe5NcMNzgounDNYMZ71wF7MojDtLCc7VC3+mMUF4bqChrzcpFhTdxq/tUOe rYWFkjBrz4QnklMj1gft6Rn/0/N0gGt2HNC+VXbxUNwppEWA0WPF1JWfyI8siubr cYLNfyB8lKWRsyqMSJ31pkGdowFronr/BCaVV7Vx/noymUmneBpomF/3jqP9wcgr V7dc/4TBVB/7wp6ACZSv1Xe0wvtesrJA+E13Z7Olyw30jsFTalH2/AO0iT8c+DBT KLH+MQONDEGddP+2Dp8n2RmZfna5lR0pBfHZmXU0uBINEVkmA8/OSfNUNEceDQZN ZRObTMDDxROHvA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:message-id :mime-version:subject:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm3; bh=kd0CSb157Xk/IONdrE69QkPk9THy9 8cRQQb48eXnGdk=; b=WmcdohmuDnT8yxfMfF7VqTQlxqbhShGERJkIn02jcTSN2 I7+FmLQm6aFaNiDPR1GlTf5v86VjvXX4mK7O36YAPOZV7WqBjAnDQ+5nfcB+RhfO E8ur8V5z9jfRYg5p83phZwu+0a4jvbe44N0O0xWhy946e9FhVGm+sc1ayT7wtFdi b6ZcNFrRjBxTX7eTs4oOHFh7spP/+XApfggGMr77GHeqLThXpFtKtGjtPIZSNxX2 g8rfKXP6je3Fnpv0NxT+NKK1yNwmCFjPMqZz6Vonp+ImdvdeC6QPMr3QGo/WWGQE Gtote4Ol7OpfijTEQru/3aeqoGxJPdVT/jOOonn6A== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduvddrkeeigdefudcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhepofgfggfkfffhvffutgesrgdtreerre erjeenucfhrhhomhepfdfoihgthhgvlhcuufgthhhinhiifdcuoehmihgthhgvlhesshgt hhhirdhniieqnecuffhomhgrihhnpehpohhrkhhrihhnugdrohhrghdpnhhumhgvrhhitg grlhdrrhgvtghiphgvshenucfrrghrrghmpehmrghilhhfrhhomhepmhhitghhvghlsehs tghhihdrnhiinecuvehluhhsthgvrhfuihiivgeptd X-ME-Proxy: Received: by mailuser.nyi.internal (Postfix, from userid 501) id E1EF53C00A1; Sat, 27 Jul 2019 06:28:21 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.1.6-736-gdfb8e44-fmstable-20190718v2 Mime-Version: 1.0 Message-Id: <5b25458e-a2ef-41ad-a329-c82dcdeee2fd@www.fastmail.com> Date: Sat, 27 Jul 2019 12:28:16 +0200 From: "Michel Schinz" To: bug-gnu-emacs@gnu.org Subject: 26.2; Calc: calc-julian produces incorrect result Content-Type: multipart/alternative; boundary=52a8bc61465742539386e9190143ac67 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 64.147.123.20 X-Spam-Score: -1.6 (-) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Sat, 27 Jul 2019 12:10:57 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.6 (--) --52a8bc61465742539386e9190143ac67 Content-Type: text/plain;charset=utf-8 Content-Transfer-Encoding: quoted-printable To reproduce: - start calc (M-x calc) - enter algebraic mode (') - enter today's date as <2019-07-27> then hit RET - convert to Julian day count (t J) - notice that the result is 2458690, which is wrong (the correct value is 2458692) Oddly enough, Emacs' calendar produces the correct value. To see this, start the calendar (M-x calendar), navigate to the date above, then press "p a". This displays the correct value: Astronomical (Julian) day number (at noon UTC): 2458692.0 To cross-check, several web sites are available to compute the Julian day number, e.g. http://numerical.recipes/julian.html In GNU Emacs 26.2 (build 1, x86_64-apple-darwin18.2.0, NS appkit-1671.20= Version 10.14.3 (Build 18D109)) of 2019-04-13 built on builder10-14.porkrind.org Windowing system distributor 'Apple', version 10.3.1671 Recent messages: For information about GNU Emacs and the GNU system, type C-h C-a. user-error: The mark is not set now, so there is no region Welcome to the GNU Emacs Calculator! Press =E2=80=98?=E2=80=99 or =E2=80= =98h=E2=80=99 for help, =E2=80=98q=E2=80=99 to quit DEL is undefined Configured using: 'configure --with-ns '--enable-locallisppath=3D/Library/Application Support/Emacs/${version}/site-lisp:/Library/Application Support/Emacs/site-lisp' --with-modules' Configured features: NOTIFY ACL GNUTLS LIBXML2 ZLIB TOOLKIT_SCROLL_BARS NS MODULES THREADS Important settings: value of $LANG: fr_CH.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 seq byte-opt gv bytecomp byte-compile cconv cl-loaddefs cl-lib dired dired-loaddefs format-spec rfc822 mml mml-sec password-cache epa derived epg epg-config= gnus-util rmail rmail-loaddefs mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils calccomp calc-arith calc-alg calc-misc calc-vec calc-forms calc-ext calc-aent calc-menu easymenu calc= calc-loaddefs calc-macs elec-pair time-date 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 menu-bar rfn-eshadow isearch timer select scroll-bar mouse jit-lock font-lock syntax facemenu font-core term/tty-colors frame 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 minibuffer cl-preloaded nadvice loaddefs button faces cus-face macroexp files text-properties overlay sha1 md5 base64 format env code-pages mule custom widget hashtable-print-readable= backquote threads kqueue cocoa ns multi-tty make-network-process emacs) Memory information: ((conses 16 238377 12447) (symbols 48 23518 1) (miscs 40 46 241) (strings 32 36281 1818) (string-bytes 1 950248) (vectors 16 37616) (vector-slots 8 761908 14102) (floats 8 51 104) (intervals 56 230 0) (buffers 992 13)) --52a8bc61465742539386e9190143ac67 Content-Type: text/html;charset=utf-8 Content-Transfer-Encoding: quoted-printable
To reproduce:
- start calc (M-x calc)
- enter algebraic mod= e (')
- enter today's date as <2019-07-27> then hit = RET
- convert to Julian day count (t J)
- no= tice that the result is 2458690, which is wrong (the correct value
  is 2458692)

Oddly enough, E= macs' calendar produces the correct value. To see this,
st= art the calendar (M-x calendar), navigate to the date above, then
press "p a". This displays the correct value:

=
Astronomical (Julian) day number (at noon UTC): 2458692.0
=

To cross-check, several web sites are availabl= e to compute the Julian


In GNU Emacs 26.2 (build 1,= x86_64-apple-darwin18.2.0, NS appkit-1671.20 Version 10.14.3 (Build 18D= 109))
of 2019-04-13 built on builder10-14.porkrind.org
=
Windowing system distributor 'Apple', version 10.3.1671
Recent messages:
For information about GNU Emacs = and the GNU system, type C-h C-a.
user-error: The mark is = not set now, so there is no region
Welcome to the GNU Emac= s Calculator!  Press =E2=80=98?=E2=80=99 or =E2=80=98h=E2=80=99 for= help, =E2=80=98q=E2=80=99 to quit
<help> DEL is und= efined

Configured using:
'con= figure --with-ns '--enable-locallisppath=3D/Library/Application
Support/Emacs/${version}/site-lisp:/Library/Application
<= div>Support/Emacs/site-lisp' --with-modules'

Configured features:
NOTIFY ACL GNUTLS LIBXML2 ZLIB TOOL= KIT_SCROLL_BARS NS MODULES THREADS

Importan= t settings:
  value of $LANG: fr_CH.UTF-8
  locale-coding-system: utf-8-unix

= Major mode: Lisp Interaction

Minor modes in= effect:
  tooltip-mode: t
  globa= l-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-f= ont-lock-mode: t
  font-lock-mode: t
&n= bsp; blink-cursor-mode: t
  auto-composition-mode: t<= br>
  auto-encryption-mode: t
  auto-c= ompression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Load-path s= hadows:
None found.

Features:=
(shadow sort mail-extr emacsbug message rmc puny seq byte= -opt gv
bytecomp byte-compile cconv cl-loaddefs cl-lib dir= ed dired-loaddefs
format-spec rfc822 mml mml-sec password-= cache epa derived epg epg-config
gnus-util rmail rmail-loa= ddefs mm-decode mm-bodies mm-encode mail-parse
rfc2231 mai= labbrev gmm-utils mailheader sendmail rfc2047 rfc2045
ietf= -drums mm-util mail-prsvr mail-utils calccomp calc-arith calc-alg
calc-misc calc-vec calc-forms calc-ext calc-aent calc-menu easym= enu calc
calc-loaddefs calc-macs elec-pair time-date toolt= ip eldoc electric
uniquify ediff-hook vc-hooks lisp-float-= type mwheel term/ns-win ns-win
ucs-normalize mule-util ter= m/common-win tool-bar dnd fontset image
regexp-opt fringe = tabulated-list replace newcomment text-mode elisp-mode
lis= p-mode prog-mode register page menu-bar rfn-eshadow isearch timer
select scroll-bar mouse jit-lock font-lock syntax facemenu font-= core
term/tty-colors frame cl-generic cham georgian utf-8-= lang misc-lang
vietnamese tibetan thai tai-viet lao korean= japanese eucjp-ms cp51932
hebrew greek romanian slovak cz= ech european ethiopic indian cyrillic
chinese composite ch= arscript charprop case-table epa-hook jka-cmpr-hook
help s= imple abbrev obarray minibuffer cl-preloaded nadvice loaddefs
<= div>button faces cus-face macroexp files text-properties overlay sha1 md= 5
base64 format env code-pages mule custom widget hashtabl= e-print-readable
backquote threads kqueue cocoa ns multi-t= ty make-network-process emacs)

Memory infor= mation:
((conses 16 238377 12447)
(symbols 4= 8 23518 1)
(miscs 40 46 241)
(strings 32 362= 81 1818)
(string-bytes 1 950248)
(vectors 16= 37616)
(vector-slots 8 761908 14102)
(float= s 8 51 104)
(intervals 56 230 0)
(buffers 99= 2 13))

--52a8bc61465742539386e9190143ac67-- From debbugs-submit-bounces@debbugs.gnu.org Tue Jul 30 07:08:27 2019 Received: (at 36822) by debbugs.gnu.org; 30 Jul 2019 11:08:27 +0000 Received: from localhost ([127.0.0.1]:49627 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hsPzX-0004Vn-5A for submit@debbugs.gnu.org; Tue, 30 Jul 2019 07:08:27 -0400 Received: from mail153c50.megamailservers.eu ([91.136.10.163]:55602 helo=mail50c50.megamailservers.eu) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hsPzT-0004VX-Sm; Tue, 30 Jul 2019 07:08:25 -0400 X-Authenticated-User: mattiase@bredband.net DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=megamailservers.eu; s=maildub; t=1564484901; bh=wMlOKae1zH3jjgZncQUY5ONESXnqse6K3EZQstrBVDc=; h=From:Subject:Date:Cc:To:From; b=eMWR5mOd7DTuR71pjGJSzQvA8F2J6GS00YVg2VplbnY3SrpoHQNDQOFDE/EaXXBZV 5ft+pWW/nmTY/O9gH5BMiI+1Gyyq1x+hOaCfCBqMXUK+jAfThFHMP35Wqcz02RmQHe ujRVmdiJ3L+UFv89hrUApr9N/Is+1XOYFeLivMio= Feedback-ID: mattiase@acm.or Received: from [192.168.0.4] ([188.150.171.71]) (authenticated bits=0) by mail50c50.megamailservers.eu (8.14.9/8.13.1) with ESMTP id x6UB8IB2010529; Tue, 30 Jul 2019 11:08:20 +0000 From: =?utf-8?Q?Mattias_Engdeg=C3=A5rd?= Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.11\)) Subject: bug#36822: 26.2; Calc: calc-julian produces incorrect result Message-Id: Date: Tue, 30 Jul 2019 13:08:18 +0200 To: michel@schi.nz X-Mailer: Apple Mail (2.3445.104.11) X-CTCH-RefID: str=0001.0A0B0201.5D402525.0021, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0 X-CTCH-VOD: Unknown X-CTCH-Spam: Unknown X-CTCH-Score: 0.000 X-CTCH-Rules: X-CTCH-Flags: 0 X-CTCH-ScoreCust: 0.000 X-CSC: 0 X-CHA: v=2.3 cv=CNcEoyjD c=1 sm=1 tr=0 a=SF+I6pRkHZhrawxbOkkvaA==:117 a=SF+I6pRkHZhrawxbOkkvaA==:17 a=kj9zAlcOel0A:10 a=COdD5iPeeLP_TaopelwA:9 a=CjuIK1q_8ugA:10 X-Spam-Score: 0.3 (/) X-Debbugs-Envelope-To: 36822 Cc: 36822@debbugs.gnu.org, control@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) tags 36822 confirmed quit Thank you; Reproduced, and it does look wrong. It looks like there are multiple flaws involved. From debbugs-submit-bounces@debbugs.gnu.org Tue Jul 30 11:51:09 2019 Received: (at 36822) by debbugs.gnu.org; 30 Jul 2019 15:51:09 +0000 Received: from localhost ([127.0.0.1]:51044 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hsUP7-00015N-0g for submit@debbugs.gnu.org; Tue, 30 Jul 2019 11:51:09 -0400 Received: from mail172c50.megamailservers.eu ([91.136.10.182]:56340 helo=mail33c50.megamailservers.eu) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hsUP3-000155-Gr; Tue, 30 Jul 2019 11:51:06 -0400 X-Authenticated-User: mattiase@bredband.net DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=megamailservers.eu; s=maildub; t=1564501863; bh=msUC34yIDDq5zUmzmDTCrk9RUQ1X5VZJ/9xF4bY+NJY=; h=Subject:From:In-Reply-To:Date:Cc:References:To:From; b=DXLbvCDzcKuNDkqBbzzeqMOLJo0jRSP9uykvjc4TEx4rOhxOFD+F2cdFlh8zmmMvB Yypvl8BVwNf8F4KettKGczY4Q/ddPnG3fj06k+HsvpqnPqmBBbZLyVMZg/oH+Wullh tbaZvR/6gq9mo6ZPvgxflymjaL7lfOOHq+mTJJMM= Feedback-ID: mattiase@acm.or Received: from [192.168.0.4] ([188.150.171.71]) (authenticated bits=0) by mail33c50.megamailservers.eu (8.14.9/8.13.1) with ESMTP id x6UFp0qg015947; Tue, 30 Jul 2019 15:51:02 +0000 Content-Type: multipart/mixed; boundary="Apple-Mail=_83D2ABDC-7861-41B2-90CD-BF34147AF6A6" Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.11\)) Subject: Re: bug#36822: 26.2; Calc: calc-julian produces incorrect result From: =?utf-8?Q?Mattias_Engdeg=C3=A5rd?= In-Reply-To: Date: Tue, 30 Jul 2019 17:51:00 +0200 Message-Id: References: To: michel@schi.nz X-Mailer: Apple Mail (2.3445.104.11) X-CTCH-RefID: str=0001.0A0B0206.5D406767.0038, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0 X-CTCH-VOD: Unknown X-CTCH-Spam: Unknown X-CTCH-Score: 0.000 X-CTCH-Rules: X-CTCH-Flags: 0 X-CTCH-ScoreCust: 0.000 X-CSC: 0 X-CHA: v=2.3 cv=GYc5YzfL c=1 sm=1 tr=0 a=SF+I6pRkHZhrawxbOkkvaA==:117 a=SF+I6pRkHZhrawxbOkkvaA==:17 a=jpOVt7BSZ2e4Z31A5e1TngXxSK0=:19 a=8IraQf0k_r41KMDgSLoA:9 a=CjuIK1q_8ugA:10 a=JZnqBebJGJOuWfoRXq0A:9 a=B2y7HmGcmWMA:10 X-Spam-Score: 0.3 (/) X-Debbugs-Envelope-To: 36822 Cc: 36822@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) --Apple-Mail=_83D2ABDC-7861-41B2-90CD-BF34147AF6A6 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii tags 36822 patch quit > It looks like there are multiple flaws involved. This was indeed the case. Attached is a patch that attempts to fix those = that I found (I didn't dig very deeply). As I'm no calendar expert, I would greatly value an independent review = of the patch. --Apple-Mail=_83D2ABDC-7861-41B2-90CD-BF34147AF6A6 Content-Disposition: attachment; filename=0001-Fix-various-Calc-date-conversions-bug-36822.patch Content-Type: application/octet-stream; x-unix-mode=0644; name="0001-Fix-various-Calc-date-conversions-bug-36822.patch" Content-Transfer-Encoding: quoted-printable =46rom=200facfe8988f7d0614d8cce124a8a7cabaf7450ed=20Mon=20Sep=2017=20= 00:00:00=202001=0AFrom:=20=3D?UTF-8?q?Mattias=3D20Engdeg=3DC3=3DA5rd?=3D=20= =0ADate:=20Tue,=2030=20Jul=202019=2017:33:19=20+0200=0A= Subject:=20[PATCH]=20Fix=20various=20Calc=20date=20conversions=20= (bug#36822)=0A=0A*=20lisp/calc/calc-forms.el=20= (math-absolute-from-gregorian-dt):=0ARewrite=20in=20a=20way=20that=20I=20= understand,=20and=20that=20actually=20seems=20to=20work.=0A= (math-absolute-from-julian-dt):=20Use=20Julian,=20not=20Gregorian,=20= leap=20year=0Arules=20for=20counting=20days=20within=20a=20year.=0A= (math-julian-date-beginning,=20math-julian-date-beginning-int):=0AChange=20= constants=20to=20be=20consistent=20with=20their=20doc=20strings=20and=20= the=20code:=0Ause=20Rata=20Die=20epoch=20at=20Dec=2031,=201=20BC=20= Gregorian=20proleptic,=20not=20Julian.=0A*=20doc/misc/calc.texi=20(Date=20= Forms):=20Correct=20difference=20between=20Julian=0ADay=20and=20Rata=20= Die.=0A*=20test/lisp/calc/calc-tests.el=20(calc-test-calendar):=20New=20= test.=0A---=0A=20doc/misc/calc.texi=20=20=20=20=20=20=20=20=20=20=20|=20=20= 4=20++--=0A=20lisp/calc/calc-forms.el=20=20=20=20=20=20|=2038=20= ++++++++++++------------------------=0A=20test/lisp/calc/calc-tests.el=20= |=2021=20++++++++++++++++++++=0A=203=20files=20changed,=2035=20= insertions(+),=2028=20deletions(-)=0A=0Adiff=20--git=20= a/doc/misc/calc.texi=20b/doc/misc/calc.texi=0Aindex=20= 75bbae58b2..c13ba8b940=20100644=0A---=20a/doc/misc/calc.texi=0A+++=20= b/doc/misc/calc.texi=0A@@=20-11055,9=20+11055,9=20@@=20Date=20Forms=0A=20= is=20the=20numbers=20of=20days=20since=2012:00=20noon=20(GMT)=20on=20= November=2024,=204714=20BC=0A=20in=20the=20Gregorian=20calendar=20(i.e.,=20= January=201,=204713=20BC=20in=20the=20Julian=0A=20calendar).=20=20In=20= Calc's=20scheme=20(in=20GMT)=20the=20Julian=20day=20origin=20is=0A= -@mathit{-1721422.5},=20because=20Calc=20starts=20at=20midnight=20= instead=20of=20noon.=0A+@mathit{-1721424.5},=20because=20Calc=20starts=20= at=20midnight=20instead=20of=20noon.=0A=20Thus=20to=20convert=20a=20Calc=20= date=20code=20obtained=20by=20unpacking=20a=0A-date=20form=20into=20a=20= Julian=20day=20number,=20simply=20add=201721422.5=20after=0A+date=20form=20= into=20a=20Julian=20day=20number,=20simply=20add=201721424.5=20after=0A=20= compensating=20for=20the=20time=20zone=20difference.=20=20The=20built-in=20= @kbd{t=20J}=0A=20command=20performs=20this=20conversion=20for=20you.=0A=20= =0Adiff=20--git=20a/lisp/calc/calc-forms.el=20b/lisp/calc/calc-forms.el=0A= index=20eb1a8248cd..71127ed779=20100644=0A---=20= a/lisp/calc/calc-forms.el=0A+++=20b/lisp/calc/calc-forms.el=0A@@=20= -585,29=20+585,15=20@@=20math-absolute-from-gregorian-dt=0A=20=20=20= "Return=20the=20DATE=20of=20the=20day=20given=20by=20the=20Gregorian=20= day=20YEAR=20MONTH=20DAY.=0A=20Recall=20that=20DATE=20is=20the=20number=20= of=20days=20since=20December=2031,=20-1=0A=20in=20the=20Gregorian=20= calendar."=0A-=20=20(if=20(eq=20year=200)=20(setq=20year=20-1))=0A-=20=20= (let=20((yearm1=20(math-sub=20year=201)))=0A-=20=20=20=20(math-sub=0A-=20= =20=20=20=20;;=20Add=20the=20number=20of=20days=20of=20the=20year=20and=20= the=20numbers=20of=20days=0A-=20=20=20=20=20;;=20in=20the=20previous=20= years=20(leap=20year=20days=20to=20be=20added=20separately)=0A-=20=20=20=20= =20(math-add=20(math-day-in-year=20year=20month=20day)=0A-=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20(math-add=20(math-mul=20365=20yearm1)=0A-=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= ;;=20Add=20the=20number=20of=20Julian=20leap=20years=0A-=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(if=20= (math-posp=20year)=0A-=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20(math-quotient=20yearm1=204)=0A-=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= (math-sub=20365=0A-=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(math-quotient=20= (math-sub=203=20year)=0A-=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=204)))))=0A-=20=20=20=20=20;;=20Subtract=20= the=20number=20of=20Julian=20leap=20years=20which=20are=20not=0A-=20=20=20= =20=20;;=20Gregorian=20leap=20years.=20=20In=20C=3D4N+r=20centuries,=20= there=20will=0A-=20=20=20=20=20;;=20be=203N+r=20of=20these=20days.=20=20= The=20following=20will=20compute=0A-=20=20=20=20=20;;=203N+r.=0A-=20=20=20= =20=20(let*=20((correction=20(math-mul=20(math-quotient=20yearm1=20100)=20= 3))=0A-=20=20=20=20=20=20=20=20=20=20=20=20(res=20(math-idivmod=20= correction=204)))=0A-=20=20=20=20=20=20=20(math-add=20(if=20(=3D=20(cdr=20= res)=200)=0A-=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =200=0A-=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=201)=0A-=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(car=20res))))))=0A+=20=20= (when=20(zerop=20year)=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20;=20Year=20-1=20precedes=20year=201.=0A+=20=20=20=20(setq=20= year=20-1))=0A+=20=20(let*=20((y=20(if=20(>=20year=200)=20year=20(+=20= year=201)))=20=20;=20Astronomical=20year=20(with=200).=0A+=20=20=20=20=20= =20=20=20=20(y1=20(-=20y=201)))=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20;=20Previous=20year.=0A+=20=20=20=20(+=20= (*=20y1=20365)=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= ;=20Days=20up=20to=20the=20previous=20year...=0A+=20=20=20=20=20=20=20= (floor=20y1=204)=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20;=20= ...=20including=20leap=20days.=0A+=20=20=20=20=20=20=20(-=20(floor=20y1=20= 100))=0A+=20=20=20=20=20=20=20(floor=20y1=20400)=0A+=20=20=20=20=20=20=20= (math-day-in-year=20year=20month=20day))))=0A=20=0A=20(defun=20= math-absolute-from-julian-dt=20(year=20month=20day)=0A=20=20=20"Return=20= the=20DATE=20of=20the=20day=20given=20by=20the=20Julian=20day=20YEAR=20= MONTH=20DAY.=0A@@=20-618,7=20+604,7=20@@=20math-absolute-from-julian-dt=0A= =20=20=20=20=20(math-sub=0A=20=20=20=20=20=20;;=20Add=20the=20number=20= of=20days=20of=20the=20year=20and=20the=20numbers=20of=20days=0A=20=20=20= =20=20=20;;=20in=20the=20previous=20years=20(leap=20year=20days=20to=20= be=20added=20separately)=0A-=20=20=20=20=20(math-add=20(math-day-in-year=20= year=20month=20day)=0A+=20=20=20=20=20(math-add=20(math-day-in-year=20= year=20month=20day=20t)=0A=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= (math-add=20(math-mul=20365=20yearm1)=0A=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20;;=20Add=20the=20number=20= of=20Julian=20leap=20years=0A=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20(if=20(math-posp=20year)=0A@@=20-712,11=20= +698,11=20@@=20math-format-date=0A=20=09=20=20=20=20=20=20=20(setcdr=20= math-fd-dt=20nil))=0A=20=09=20=20fmt))))=0A=20=0A-(defconst=20= math-julian-date-beginning=20'(float=2017214225=20-1)=0A+(defconst=20= math-julian-date-beginning=20'(float=2017214245=20-1)=0A=20=20=20"The=20= beginning=20of=20the=20Julian=20date=20calendar,=0A=20as=20measured=20in=20= the=20number=20of=20days=20before=20December=2031,=201=20BC=20= (Gregorian).")=0A=20=0A-(defconst=20math-julian-date-beginning-int=20= 1721423=0A+(defconst=20math-julian-date-beginning-int=201721425=0A=20=20=20= "The=20beginning=20of=20the=20Julian=20date=20calendar,=0A=20as=20= measured=20in=20the=20integer=20number=20of=20days=20before=20December=20= 31,=201=20BC=20(Gregorian).")=0A=20=0Adiff=20--git=20= a/test/lisp/calc/calc-tests.el=20b/test/lisp/calc/calc-tests.el=0Aindex=20= 77d939eb40..e1ee20b5d2=20100644=0A---=20a/test/lisp/calc/calc-tests.el=0A= +++=20b/test/lisp/calc/calc-tests.el=0A@@=20-193,6=20+193,27=20@@=20= calc-tests-simple=0A=20=20=20=20=20(let=20((calc-number-radix=2036))=0A=20= =20=20=20=20=20=20(should=20(equal=20(math-format-number=2012345678901)=20= "36#5,O6A,QT1")))))=0A=20=0A+(ert-deftest=20calc-test-calendar=20()=0A+=20= =20"Test=20calendar=20conversions=20(bug#36822)."=0A+=20=20(should=20= (equal=20(calcFunc-julian=20(math-parse-date=20"2019-07-27"))=20= 2458692))=0A+=20=20(should=20(equal=20(math-parse-date=20"2019-07-27")=20= '(date=20737267)))=0A+=20=20(should=20(equal=20(calcFunc-julian=20'(date=20= 0))=201721425))=0A+=20=20(should=20(equal=20(math-date-to-gregorian-dt=20= 1)=20'(1=201=201)))=0A+=20=20(should=20(equal=20= (math-date-to-gregorian-dt=200)=20'(-1=2012=2031)))=0A+=20=20(should=20= (equal=20(math-date-to-gregorian-dt=20-1721425)=20'(-4714=2011=2024)))=0A= +=20=20(should=20(equal=20(math-absolute-from-gregorian-dt=202019=207=20= 27)=20737267))=0A+=20=20(should=20(equal=20= (math-absolute-from-gregorian-dt=201=201=201)=201))=0A+=20=20(should=20= (equal=20(math-absolute-from-gregorian-dt=20-1=2012=2031)=200))=0A+=20=20= (should=20(equal=20(math-absolute-from-gregorian-dt=20-99=2012=2031)=20= -35795))=0A+=20=20(should=20(equal=20(math-absolute-from-gregorian-dt=20= -4714=2011=2024)=20-1721425))=0A+=20=20(should=20(equal=20= (calcFunc-julian=20'(date=20-1721425))=200))=0A+=20=20(should=20(equal=20= (math-date-to-julian-dt=201)=20'(1=201=203)))=0A+=20=20(should=20(equal=20= (math-date-to-julian-dt=20-1721425)=20'(-4713=201=201)))=0A+=20=20= (should=20(equal=20(math-absolute-from-julian-dt=202019=201=201)=20= 737073))=0A+=20=20(should=20(equal=20(math-absolute-from-julian-dt=201=20= 1=203)=201))=0A+=20=20(should=20(equal=20(math-absolute-from-julian-dt=20= -101=201=201)=20-36892))=0A+=20=20(should=20(equal=20= (math-absolute-from-julian-dt=20-101=203=201)=20-36832))=0A+=20=20= (should=20(equal=20(math-absolute-from-julian-dt=20-4713=201=201)=20= -1721425)))=0A=20=0A=20(provide=20'calc-tests)=0A=20;;;=20calc-tests.el=20= ends=20here=0A--=20=0A2.20.1=20(Apple=20Git-117)=0A=0A= --Apple-Mail=_83D2ABDC-7861-41B2-90CD-BF34147AF6A6-- From debbugs-submit-bounces@debbugs.gnu.org Tue Aug 06 08:04:24 2019 Received: (at 36822-done) by debbugs.gnu.org; 6 Aug 2019 12:04:24 +0000 Received: from localhost ([127.0.0.1]:36560 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1huyCV-00070s-LW for submit@debbugs.gnu.org; Tue, 06 Aug 2019 08:04:24 -0400 Received: from mail158c50.megamailservers.eu ([91.136.10.168]:53490 helo=mail51c50.megamailservers.eu) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1huyCT-00070j-Vi for 36822-done@debbugs.gnu.org; Tue, 06 Aug 2019 08:04:22 -0400 X-Authenticated-User: mattiase@bredband.net DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=megamailservers.eu; s=maildub; t=1565093060; bh=MZyzReaYtk6vtfCprQBXekSHNfr6AFiQdN1NSvzge0o=; h=Subject:From:In-Reply-To:Date:Cc:References:To:From; b=ELhiH5Il/zfLlb+S0NRHLM3nb9dKHol8q24S8GJHnRTi1GTu5/fbccDN6SrMb6x1V FKGDDNbj4tL/aKvsMXipYy173oXxy17uf6JkkF1LbiS8I/0gaJhpJIoX+BzeuDyNuM 94jZtIw8HNS9Xuy1Ikuj4RUyQSmrGA/dyBbpHOFU= Feedback-ID: mattiase@acm.or Received: from [192.168.1.64] (c-e636e253.032-75-73746f71.bbcust.telenor.se [83.226.54.230]) (authenticated bits=0) by mail51c50.megamailservers.eu (8.14.9/8.13.1) with ESMTP id x76C4IhE026822; Tue, 6 Aug 2019 12:04:19 +0000 Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.11\)) Subject: Re: bug#36822: 26.2; Calc: calc-julian produces incorrect result From: =?utf-8?Q?Mattias_Engdeg=C3=A5rd?= In-Reply-To: Date: Tue, 6 Aug 2019 14:04:17 +0200 Content-Transfer-Encoding: quoted-printable Message-Id: <2DA7B011-1959-4CEA-A1E6-97F3E45DB7AA@acm.org> References: To: michel@schi.nz X-Mailer: Apple Mail (2.3445.104.11) X-CTCH-RefID: str=0001.0A0B0208.5D496CC4.0028, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0 X-CTCH-VOD: Unknown X-CTCH-Spam: Unknown X-CTCH-Score: 0.000 X-CTCH-Rules: X-CTCH-Flags: 0 X-CTCH-ScoreCust: 0.000 X-CSC: 0 X-CHA: v=2.3 cv=U6m889ju c=1 sm=1 tr=0 a=M+GU/qJco4WXjv8D6jB2IA==:117 a=M+GU/qJco4WXjv8D6jB2IA==:17 a=jpOVt7BSZ2e4Z31A5e1TngXxSK0=:19 a=kj9zAlcOel0A:10 a=YvNXHQcnZklDD7DfjvEA:9 a=CjuIK1q_8ugA:10 X-Spam-Score: 0.3 (/) X-Debbugs-Envelope-To: 36822-done Cc: 36822-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) Patch pushed to master; it should at least make the code no worse than = before. Thanks for reporting the bug! From unknown Fri Jun 20 07:19:51 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Wed, 04 Sep 2019 11:24:04 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator