unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#19063: [FIX] Calc computing max of a vector of dates
@ 2014-11-15 17:58 Thierry Banel
       [not found] ` <87389jhfxu.fsf@gmail.com>
  0 siblings, 1 reply; 2+ messages in thread
From: Thierry Banel @ 2014-11-15 17:58 UTC (permalink / raw)
  To: 19063

Hi the list.

* Description
In Calc there is a bug when computing the max or min of a vector of dates.
The fix is quite simple (change a car to a caar)

* Unit testing
 M-x calc     launch Calc
 t N          insert "now" date-time
 7+           add 7 days (or whatever)
 t N          insert "now" again
 Esc 2 v p    pack both date-times in a vector
 u X          call calc-vector-max

==> result with the bug:
    vmax([<7:36:14pm Thu Nov 20, 2014>,
          <7:36:54pm Thu Nov 13, 2014>])

==> result with the fix:
    <7:36:14pm Thu Nov 20, 2014>

This test also works with "min" instead of "max"
and
  u N
instead of
  u X

* ChangeLog

    2014-11-13 Thierry Banel <tbanelwebmin@free.fr>

    * calc-arith.el (math-max-list, math-min-list): fix bug
    for date handling.

* Patch
*** calc-arith.el-old    2014-11-13 19:58:13.159676097 +0100
--- calc-arith.el-new    2014-11-13 20:00:01.886392943 +0100
***************
*** 2249,2255 ****
 
  (defun math-min-list (a b)
    (if b
!       (if (or (Math-anglep (car b)) (eq (car b) 'date)
            (and (eq (car (car b)) 'intv) (math-intv-constp (car b)))
            (math-infinitep (car b)))
        (math-min-list (math-min a (car b)) (cdr b))
--- 2249,2255 ----
 
  (defun math-min-list (a b)
    (if b
!       (if (or (Math-anglep (car b)) (eq (caar b) 'date)
            (and (eq (car (car b)) 'intv) (math-intv-constp (car b)))
            (math-infinitep (car b)))
        (math-min-list (math-min a (car b)) (cdr b))
***************
*** 2279,2285 ****
 
  (defun math-max-list (a b)
    (if b
!       (if (or (Math-anglep (car b)) (eq (car b) 'date)
            (and (eq (car (car b)) 'intv) (math-intv-constp (car b)))
            (math-infinitep (car b)))
        (math-max-list (math-max a (car b)) (cdr b))
--- 2279,2285 ----
 
  (defun math-max-list (a b)
    (if b
!       (if (or (Math-anglep (car b)) (eq (caar b) 'date)
            (and (eq (car (car b)) 'intv) (math-intv-constp (car b)))
            (math-infinitep (car b)))
        (math-max-list (math-max a (car b)) (cdr b))






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

* bug#19063: Fwd: Re: bug#19063: [FIX] Calc computing max of a vector of dates
       [not found] ` <87389jhfxu.fsf@gmail.com>
@ 2014-11-16  5:36   ` Jay Belanger
  0 siblings, 0 replies; 2+ messages in thread
From: Jay Belanger @ 2014-11-16  5:36 UTC (permalink / raw)
  To: 19063-done

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

---------- Forwarded message ----------
From: "Jay Belanger" <jay.p.belanger@gmail.com>
Date: Nov 15, 2014 11:28 PM
Subject: Re: bug#19063: [FIX] Calc computing max of a vector of dates
To: <done-19063@debbugs.gnu.org>
Cc: <jay.p.belanger@gmail.com>


Thanks; I've committed your fix.

Jay

[-- Attachment #2: Type: text/html, Size: 557 bytes --]

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

end of thread, other threads:[~2014-11-16  5:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-11-15 17:58 bug#19063: [FIX] Calc computing max of a vector of dates Thierry Banel
     [not found] ` <87389jhfxu.fsf@gmail.com>
2014-11-16  5:36   ` bug#19063: Fwd: " Jay Belanger

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).