emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Ivan Vilata i Balaguer <ivan@selidor.net>
To: emacs-orgmode@gnu.org
Subject: [PATCH] Allow relative times in clocktable tstart and tend options
Date: Thu, 22 Nov 2012 00:07:33 +0100	[thread overview]
Message-ID: <20121121230733.GA15586@edgar.selidor.net> (raw)

* 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.

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
---
 doc/org.texi      |    4 ++++
 lisp/org-clock.el |    4 ++--
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/doc/org.texi b/doc/org.texi
index bf67876..c88b745 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{"<now>"} 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.}
diff --git a/lisp/org-clock.el b/lisp/org-clock.el
index 54e4018..6595330 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)
-- 
1.7.10.4


-- 
Ivan Vilata i Balaguer -- https://elvil.net/

             reply	other threads:[~2012-11-21 23:07 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-21 23:07 Ivan Vilata i Balaguer [this message]
2012-11-28 12:47 ` [PATCH] Allow relative times in clocktable tstart and tend options Nicolas Goaziou
2012-11-28 16:11   ` Ivan Vilata i Balaguer
2012-11-28 22:32     ` Ivan Vilata i Balaguer
2012-11-30 15:31       ` Nicolas Goaziou
2012-11-30 23:09         ` Ivan Vilata i Balaguer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20121121230733.GA15586@edgar.selidor.net \
    --to=ivan@selidor.net \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).