all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Thierry Banel <tbanelwebmin@free.fr>
To: 19063@debbugs.gnu.org
Subject: bug#19063: [FIX] Calc computing max of a vector of dates
Date: Sat, 15 Nov 2014 18:58:55 +0100	[thread overview]
Message-ID: <5467945F.2060609@free.fr> (raw)

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	other threads:[~2014-11-15 17:58 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-15 17:58 Thierry Banel [this message]
     [not found] ` <87389jhfxu.fsf@gmail.com>
2014-11-16  5:36   ` bug#19063: Fwd: Re: bug#19063: [FIX] Calc computing max of a vector of dates Jay Belanger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5467945F.2060609@free.fr \
    --to=tbanelwebmin@free.fr \
    --cc=19063@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.