emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Ilya Shlyakhter <ilya_shl@alum.mit.edu>
To: emacs-orgmode@gnu.org
Subject: [PATCH] Time specifications: Allow specifying relative times
Date: Fri, 30 Mar 2012 21:32:55 -0400	[thread overview]
Message-ID: <jl5ms8$ap2$1@dough.gmane.org> (raw)

[-- Attachment #1: Type: text/plain, Size: 394 bytes --]

When specifying times in the tags/properties matcher you can use 
relative time notation, such as <yesterday> or <-1w>.  This patch
allows this to be used in other places, such as the :tstart and :tend
parameters of clocktable.

Btw, I couldn't quite understand the exact meaning of :block, :tstart 
and :tend as decribed in the manual.  Is there a better explanation
somewhere?

thanks,

ilya

[-- Attachment #2: 0001-Time-specifications-Allow-specifying-relative-times.patch --]
[-- Type: text/plain, Size: 2021 bytes --]

From d19778b3fc624e14237d69cc76a4aa9cb8450697 Mon Sep 17 00:00:00 2001
From: Ilya Shlyakhter <ilya_shl@alum.mit.edu>
Date: Fri, 30 Mar 2012 21:19:12 -0400
Subject: [PATCH] Time specifications: Allow specifying relative times

* org.el (org-parse-time-string): Allow strings supported by tags/properties
matcher (eg <now>, <yesterday>, <-7d>) if the time starts with < and ends
with >.  This means that e.g. in the clocktable parameters you can specify
:tstart "<-1w>" :tend "<now>".

TINYCHANGE
---
 lisp/org.el |   23 +++++++++++++----------
 1 file changed, 13 insertions(+), 10 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index 4d2ae87..995dffd 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -16016,16 +16016,19 @@ When SHOW-ALL is nil, only return the current occurrence of a time stamp."
 This should be a lot faster than the normal `parse-time-string'.
 If time is not given, defaults to 0:00.  However, with optional NODEFAULT,
 hour and minute fields will be nil if not given."
-  (if (string-match org-ts-regexp0 s)
-      (list 0
-	    (if (or (match-beginning 8) (not nodefault))
-		(string-to-number (or (match-string 8 s) "0")))
-	    (if (or (match-beginning 7) (not nodefault))
-		(string-to-number (or (match-string 7 s) "0")))
-	    (string-to-number (match-string 4 s))
-	    (string-to-number (match-string 3 s))
-	    (string-to-number (match-string 2 s))
-	    nil nil nil)
+  (cond
+   ((string-match "^<.+>$" s)
+    (decode-time (seconds-to-time (org-matcher-time s))))
+   ((string-match org-ts-regexp0 s)
+    (list 0
+	  (if (or (match-beginning 8) (not nodefault))
+	      (string-to-number (or (match-string 8 s) "0")))
+	  (if (or (match-beginning 7) (not nodefault))
+	      (string-to-number (or (match-string 7 s) "0")))
+	  (string-to-number (match-string 4 s))
+	  (string-to-number (match-string 3 s))
+	  (string-to-number (match-string 2 s))
+	  nil nil nil))
     (error "Not a standard Org-mode time string: %s" s)))
 
 (defun org-timestamp-up (&optional arg)
-- 
1.7.9.3


             reply	other threads:[~2012-03-31  1:33 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-31  1:32 Ilya Shlyakhter [this message]
2012-03-31  7:05 ` [PATCH] Time specifications: Allow specifying relative times Sebastien Vauban
2012-04-20 11:13 ` Bastien
2012-11-08 17:47   ` Ivan Vilata i Balaguer
2012-11-13 22:02     ` Bastien
2012-11-14  0:07       ` Ivan Vilata i Balaguer
2012-11-14 19:44         ` Achim Gratz
2012-11-14 22:53           ` Ivan Vilata i Balaguer
2012-12-30  9:28             ` Bastien

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='jl5ms8$ap2$1@dough.gmane.org' \
    --to=ilya_shl@alum.mit.edu \
    --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).