From bc8a90da1db88ec7a57b5791fd3d9fc0e17ff9aa Mon Sep 17 00:00:00 2001 From: Carsten Dominik Date: Tue, 13 Jan 2009 10:33:50 +0100 Subject: [PATCH] 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>" 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. --- lisp/ChangeLog | 5 +++++ lisp/org.el | 14 +++++++------- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index b33c0bcea..2c1f400aa 100755 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2009-01-13 Carsten Dominik + + * 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 * org-archive.el (org-extract-archive-heading): Allow %s for file diff --git a/lisp/org.el b/lisp/org.el index 21c5175d6..f9db5162b 100644 --- a/lisp/org.el +++ b/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) -- 2.11.4.GIT