Browse Source

Bugfix: Make sure property time comparison works correctly.

Hsiu-Khuern Tang writes:

    I find that doing a tags search for SCHEDULED or DEADLINE turns
    up headings that do not have any schedule or deadlines.

    Using the example from
    http://article.gmane.org/gmane.emacs.orgmode/10274:

    #+SEQ_TODO: NEXT WAITING | DONE
    #+STARTUP: overview

    * DONE Test1
       CLOSED: [2009-01-07 Wed 12:26]

    * NEXT Test2
       DEADLINE: <2009-01-28 Wed>

    * Test3

    If I type

       C-c \ +DEADLINE<="<2009-01-28>" <RET>

    all three headlines are selected!  I expected to match the second
    headline only.

Indeed, this exposes an error in the time comparison functions
which would take a empty time stamp to mean 0.  This commit does
fix the bug.
Carsten Dominik 16 years ago
parent
commit
bc8a90da1d
2 changed files with 12 additions and 7 deletions
  1. 5 0
      lisp/ChangeLog
  2. 7 7
      lisp/org.el

+ 5 - 0
lisp/ChangeLog

@@ -1,3 +1,8 @@
+2009-01-13  Carsten Dominik  <carsten.dominik@gmail.com>
+
+	* org.el (org-time=, org-time<, org-time<=, org-time>)
+	(org-time>=, org-time<>): Make sure both values are dates.
+
 2009-01-11  Carsten Dominik  <carsten.dominik@gmail.com>
 
 	* org-archive.el (org-extract-archive-heading): Allow %s for file

+ 7 - 7
lisp/org.el

@@ -9575,16 +9575,16 @@ also TODO lines."
 (defun org-string>= (a b) (not (string< a b)))
 (defun org-string>  (a b) (and (not (string= a b)) (not (string< a b))))
 (defun org-string<> (a b) (not (string= a b)))
-(defun org-time=  (a b) (=     (org-2ft a) (org-2ft b)))
-(defun org-time<  (a b) (<     (org-2ft a) (org-2ft b)))
-(defun org-time<= (a b) (<=    (org-2ft a) (org-2ft b)))
-(defun org-time>  (a b) (>     (org-2ft a) (org-2ft b)))
-(defun org-time>= (a b) (>=    (org-2ft a) (org-2ft b)))
-(defun org-time<> (a b) (org<> (org-2ft a) (org-2ft b)))
+(defun org-time=  (a b) (setq a (org-2ft a) b (org-2ft b)) (and (> a 0) (> b 0) (=     a b)))
+(defun org-time<  (a b) (setq a (org-2ft a) b (org-2ft b)) (and (> a 0) (> b 0) (<     a b)))
+(defun org-time<= (a b) (setq a (org-2ft a) b (org-2ft b)) (and (> a 0) (> b 0) (<=    a b)))
+(defun org-time>  (a b) (setq a (org-2ft a) b (org-2ft b)) (and (> a 0) (> b 0) (>     a b)))
+(defun org-time>= (a b) (setq a (org-2ft a) b (org-2ft b)) (and (> a 0) (> b 0) (>=    a b)))
+(defun org-time<> (a b) (setq a (org-2ft a) b (org-2ft b)) (and (> a 0) (> b 0) (org<> a b)))
 (defun org-2ft (s)
   "Convert S to a floating point time.
 If S is already a number, just return it.  If it is a string, parse
-it as a time string and apply `float-time' to it.  f S is nil, just return 0."
+it as a time string and apply `float-time' to it.  If S is nil, just return 0."
   (cond
    ((numberp s) s)
    ((stringp s)