Parcourir la source

Fix issues with property time tests.

There was a bug in the implementation of the "<today>" tag for time
comparison during property matching, and new tags "<yesterday>" and
"<tomorrow>" have been introduced.

Patch by Piotr Zielinski.
Carsten Dominik il y a 16 ans
Parent
commit
c210ba6d90
3 fichiers modifiés avec 19 ajouts et 6 suppressions
  1. 4 3
      doc/org.texi
  2. 4 0
      lisp/ChangeLog
  3. 11 3
      lisp/org.el

+ 4 - 3
doc/org.texi

@@ -3895,9 +3895,10 @@ quotes, a string comparison is done, and the same operators are allowed.
 If the comparison value is enclosed in double quotes @emph{and} angular
 brackets (like @samp{DEADLINE<="<2008-12-24 18:30>"}), both values are
 assumed to be date/time specifications in the standard Org way@footnote{The
-only special values that will be recognized are @samp{"<now>"} for now, and
-@samp{"<today>"} today at 0:00 hours, i.e. without a time specification.}, and
-the comparison will be done accordingly.
+only special values that will be recognized are @samp{"<now>"} for now
+(including time), and @samp{"<today>"}, @samp{<tomorrow>}, and
+@samp{<yesterday>} for these days at 0:00 hours, i.e. without a time
+specification.}, and the comparison will be done accordingly.
 @item
 If the comparison value is enclosed
 in curly braces, a regexp match is performed, with @samp{=} meaning that the

+ 4 - 0
lisp/ChangeLog

@@ -1,5 +1,9 @@
 2008-11-17  Carsten Dominik  <carsten.dominik@gmail.com>
 
+	* org.el (org-time-today): New function.
+	(org-matcher-time): Use `org-time-today'.  Add special treatment
+	for "<tomorrow>" and "<yesterday>".
+
 	* org-exp.el (org-export-format-source-code): Fix bug in require
 	htmlize code.
 	(org-export-target-internal-links): Fix bug in search for text

+ 11 - 3
lisp/org.el

@@ -9256,11 +9256,19 @@ it as a time string and apply `float-time' to it.  f S is nil, just return 0."
       (error 0.)))
    (t 0.)))
 
+(defun org-time-today ()
+  "Time in seconds today at 0:00.
+Returns the float number of seconds since the beginning of the
+epoch to the beginning of today (00:00)."
+  (float-time (apply 'encode-time
+		     (append '(0 0 0) (nthcdr 3 (decode-time))))))
+
 (defun org-matcher-time (s)
   (cond
-   ((equal s "<now>") (float-time))
-   ((equal s "<today>")
-    (float-time (append '(0 0 0) (nthcdr 3 (decode-time)))))
+   ((string= s "<now>") (float-time))
+   ((string= s "<today>") (org-time-today))
+   ((string= s "<tomorrow>") (+ 86400.0 (org-time-today)))
+   ((string= s "<yesterday>") (- (org-time-today) 86400.0))
    (t (org-2ft s))))
 
 (defun org-match-any-p (re list)