bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


From: Thierry Banel
Subject: bug#19063: [FIX] Calc computing max of a vector of dates
Date: Sat, 15 Nov 2014 18:58:55 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.0

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






reply via email to

[Prev in Thread] Current Thread [Next in Thread]