New ways to specify time comparison values in property searches.

In addition to "<now>", "<today>", "<yesterday>", and
"<tomorrow>", there are more special values accepted now in
time comparisons in property searches:  You may use strings
like =<+3d>= or =<-2w>=, with units d, w, m, and y for day,
week, month, and year, respectively

Thanks to Linday Todd for this proposal.
This commit is contained in:
Carsten Dominik 2008-11-29 18:49:30 +01:00
parent 0bb7429c3d
commit 269c5a85bc
5 changed files with 38 additions and 11 deletions

View File

@ -89,6 +89,16 @@
A new option, `org-tags-exclude-from-inheritance', allows to
specify an exclusion list for inherited tags.
*** More special values for time comparisons in property searches
In addition to =<now>=, =<today>=, =<yesterday>=, and
=<tomorrow>=, there are more special values accepted now in
time comparisons in property searches: You may use strings
like =<+3d>= or =<-2w>=, with units d, w, m, and y for day,
week, month, and year, respectively
Thanks to Linday Todd for this proposal.
* Version 6.13
** Overview

View File

@ -1,3 +1,8 @@
2008-11-29 Carsten Dominik <carsten.dominik@gmail.com>
* org.texi (Property searches): Document new special values for
time comparisons.
2008-11-27 Carsten Dominik <carsten.dominik@gmail.com>
* org.texi (Tag inheritance): Refine the description of tag

View File

@ -3903,11 +3903,13 @@ quotes, a string comparison is done, and the same operators are allowed.
@item
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
(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.
assumed to be date/time specifications in the standard Org way, and the
comparison will be done accordingly. Special values that will be recognized
are @code{"<now>"} for now (including time), and @code{"<today>"}, and
@code{"<tomorrow>"} for these days at 0:00 hours, i.e. without a time
specification. Also strings like @code{"<+5d>"} or @code{"<-2m>"} with units
@code{d}, @code{w}, @code{m}, and @code{y} for day, week, month, and year,
respectively, can be used.
@item
If the comparison value is enclosed
in curly braces, a regexp match is performed, with @samp{=} meaning that the

View File

@ -1,5 +1,7 @@
2008-11-29 Carsten Dominik <carsten.dominik@gmail.com>
* org.el (org-matcher-time): Recognize more special values.
* org-gnus.el (fboundp): Fix defvaralias for XEmacs.
2008-11-27 Carsten Dominik <carsten.dominik@gmail.com>

View File

@ -9342,12 +9342,20 @@ epoch to the beginning of today (00:00)."
(append '(0 0 0) (nthcdr 3 (decode-time))))))
(defun org-matcher-time (s)
(cond
((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))))
"Interprete a time comparison value."
(save-match-data
(cond
((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))
((string-match "^<\\([-+][0-9]+\\)\\([dwmy]\\)>$" s)
(+ (org-time-today)
(* (string-to-number (match-string 1 s))
(cdr (assoc (match-string 2 s)
'(("d" . 86400.0) ("w" . 604800.0)
("m" . 2678400.0) ("y" . 31557600.0)))))))
(t (org-2ft s)))))
(defun org-match-any-p (re list)
"Does re match any element of list?"