From: Ivan Vilata i Balaguer Date: Wed, 28 Nov 2012 19:57:55 +0000 (+0100) Subject: Allow relative times in clocktable tstart and tend options X-Git-Tag: release_8.0-pre~769 X-Git-Url: https://repo.or.cz/w/org-mode.git/commitdiff_plain/513507ee743ab2cb99c1781ebb2d9c1c49df5485 Allow relative times in clocktable tstart and tend options * lisp/org-clock.el (org-clock-get-table-data): Pass tstart and tend time strings through `org-matcher-time' to allow relative times besides absolute ones, convert result to encoded time. * doc/org.texi (The clock table): Document acceptance of relative times in tstart and tend, link to syntax description and provide example. Inspired in the original relative times proposal by Ilya Shlyakhter, this is less invasive and it doesn't modify core functions, thus it avoids the original's infinite recursion when hitting normal dates in other locations. TINYCHANGE --- diff --git a/doc/org.texi b/doc/org.texi index bf6787678..e3a40ecdd 100644 --- a/doc/org.texi +++ b/doc/org.texi @@ -6263,7 +6263,11 @@ be selected: thisyear, lastyear, thisyear-@var{N} @r{a relative year} @r{Use @kbd{S-@key{left}/@key{right}} keys to shift the time interval.} :tstart @r{A time string specifying when to start considering times.} + @r{Relative times like @code{"<-2w>"} can also be used. See} + @r{@ref{Matching tags and properties} for relative time syntax.} :tend @r{A time string specifying when to stop considering times.} + @r{Relative times like @code{""} can also be used. See} + @r{@ref{Matching tags and properties} for relative time syntax.} :step @r{@code{week} or @code{day}, to split the table into chunks.} @r{To use this, @code{:block} or @code{:tstart}, @code{:tend} are needed.} :stepskip0 @r{Do not show steps that have zero time.} @@ -6314,6 +6318,11 @@ only to fit it into the manual.} :tend "<2006-08-10 Thu 12:00>" #+END: clocktable @end example +A range starting a week ago and ending right now could be written as +@example +#+BEGIN: clocktable :tstart "<-1w>" :tend "" +#+END: clocktable +@end example A summary of the current subtree with % times would be @example #+BEGIN: clocktable :scope subtree :link t :formula % diff --git a/lisp/org-clock.el b/lisp/org-clock.el index 54e4018bd..659533020 100644 --- a/lisp/org-clock.el +++ b/lisp/org-clock.el @@ -2604,9 +2604,9 @@ TIME: The sum of all time spend in this tree, in minutes. This time (setq te (format "%4d-%02d-%02d" (nth 2 te) (car te) (nth 1 te)))) ;; Now the times are strings we can parse. (if ts (setq ts (org-float-time - (apply 'encode-time (org-parse-time-string ts))))) + (seconds-to-time (org-matcher-time ts))))) (if te (setq te (org-float-time - (apply 'encode-time (org-parse-time-string te))))) + (seconds-to-time (org-matcher-time te))))) (save-excursion (org-clock-sum ts te (unless (null matcher)