Subject: bug#19063: closed (Fwd: Re: bug#19063: [FIX] Calc computing max of a vector of dates)

From: [email-masked] (GNU bug Tracking System)
Date: Sun, 16 Nov 2014 05:37:02 +0000

Your bug report

#19063: [FIX] Calc computing max of a vector of dates

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
19063: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=19063
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Fwd: Re: bug#19063: [FIX] Calc computing max of a vector of dates
From: Jay Belanger <[email-masked]>
To: [email-masked]
Date: Sat, 15 Nov 2014 23:36:10 -0600
List-Id: <debbugs-submit.debbugs.gnu.org>

---------- Forwarded message ----------
From: "Jay Belanger" <[email-masked]>
Date: Nov 15, 2014 11:28 PM
Subject: Re: bug#19063: [FIX] Calc computing max of a vector of dates
To: <[email-masked]>
Cc: <[email-masked]>

Thanks; I've committed your fix.

Jay

Subject: [FIX] Calc computing max of a vector of dates
From: Thierry Banel <[email-masked]>
To: [email-masked]
Date: Sat, 15 Nov 2014 18:58:55 +0100
List-Id: <debbugs-submit.debbugs.gnu.org>

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 <[email-masked]>

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