From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ilya Shlyakhter Subject: [PATCH] Time specifications: Allow specifying relative times Date: Fri, 30 Mar 2012 21:32:55 -0400 Message-ID: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------070205060301060601070106" Return-path: Received: from eggs.gnu.org ([208.118.235.92]:50827) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SDnBn-0006Cz-Sk for emacs-orgmode@gnu.org; Fri, 30 Mar 2012 21:33:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SDnBm-0001Dn-1n for emacs-orgmode@gnu.org; Fri, 30 Mar 2012 21:33:11 -0400 Received: from plane.gmane.org ([80.91.229.3]:56061) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SDnBl-0001DK-Qz for emacs-orgmode@gnu.org; Fri, 30 Mar 2012 21:33:09 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1SDnBj-0002zz-Sa for emacs-orgmode@gnu.org; Sat, 31 Mar 2012 03:33:07 +0200 Received: from dhcp-140-247-108-225.fas.harvard.edu ([140.247.108.225]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 31 Mar 2012 03:33:07 +0200 Received: from ilya_shl by dhcp-140-247-108-225.fas.harvard.edu with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 31 Mar 2012 03:33:07 +0200 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org This is a multi-part message in MIME format. --------------070205060301060601070106 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit When specifying times in the tags/properties matcher you can use relative time notation, such as 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 --------------070205060301060601070106 Content-Type: text/plain; charset=UTF-8; x-mac-type="0"; x-mac-creator="0"; name="0001-Time-specifications-Allow-specifying-relative-times.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0001-Time-specifications-Allow-specifying-relative-times.pat"; filename*1="ch" >From d19778b3fc624e14237d69cc76a4aa9cb8450697 Mon Sep 17 00:00:00 2001 From: Ilya Shlyakhter 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 , , <-7d>) if the time starts with < and ends with >. This means that e.g. in the clocktable parameters you can specify :tstart "<-1w>" :tend "". 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 --------------070205060301060601070106--