emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] Time specifications: Allow specifying relative times
@ 2012-03-31  1:32 Ilya Shlyakhter
  2012-03-31  7:05 ` Sebastien Vauban
  2012-04-20 11:13 ` Bastien
  0 siblings, 2 replies; 9+ messages in thread
From: Ilya Shlyakhter @ 2012-03-31  1:32 UTC (permalink / raw)
  To: emacs-orgmode

[-- 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


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2012-12-30  9:28 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-31  1:32 [PATCH] Time specifications: Allow specifying relative times Ilya Shlyakhter
2012-03-31  7:05 ` 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

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