* [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
* Re: [PATCH] Time specifications: Allow specifying relative times
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
1 sibling, 0 replies; 9+ messages in thread
From: Sebastien Vauban @ 2012-03-31 7:05 UTC (permalink / raw)
To: emacs-orgmode-mXXj517/zsQ
Hi Ilya,
Ilya Shlyakhter wrote:
> 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?
The block allows you to specify some chunk which is definable easily:
- yesterday
- lastweek
- thismonth
- 2012-02
- 2012-03-30
- etc.
#+BEGIN: clocktable :scope ("file.org") :block 2012-02
#+END:
`tstart' and `tend' serve for when you want to specify some range of dates
which is not expressable that way: for example, last Monday (`tstart') to
Wednesday (`tend').
Best regards,
Seb
--
Sebastien Vauban
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] Time specifications: Allow specifying relative times
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
1 sibling, 1 reply; 9+ messages in thread
From: Bastien @ 2012-04-20 11:13 UTC (permalink / raw)
To: Ilya Shlyakhter; +Cc: emacs-orgmode
Hi Ilya,
Ilya Shlyakhter <ilya_shl@alum.mit.edu> writes:
> 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.
Applied, thanks!
--
Bastien
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] Time specifications: Allow specifying relative times
2012-04-20 11:13 ` Bastien
@ 2012-11-08 17:47 ` Ivan Vilata i Balaguer
2012-11-13 22:02 ` Bastien
0 siblings, 1 reply; 9+ messages in thread
From: Ivan Vilata i Balaguer @ 2012-11-08 17:47 UTC (permalink / raw)
To: emacs-orgmode
Bastien (2012-04-20 13:13:12 +0200) wrote:
> Ilya Shlyakhter <ilya_shl@alum.mit.edu> writes:
>
>> 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.
>
> Applied, thanks!
This is a very useful patch for allowing "sliding windows" of time,
e.g. to know "how much time have I clocked during the last four weeks?".
However, I'm looking at the Git master branch and I see that the patch
hasn't actually been applied [there][1] yet (and the [original
thread][2] is from March). Is there any problem with it? Am I looking
at the wrong repo?
[1]: http://orgmode.org/cgit.cgi/org-mode.git/tree/lisp/org.el#n16359
[2]: http://comments.gmane.org/gmane.emacs.orgmode/54101
Thanks a lot,
--
Ivan Vilata i Balaguer -- https://elvil.net/
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] Time specifications: Allow specifying relative times
2012-11-08 17:47 ` Ivan Vilata i Balaguer
@ 2012-11-13 22:02 ` Bastien
2012-11-14 0:07 ` Ivan Vilata i Balaguer
0 siblings, 1 reply; 9+ messages in thread
From: Bastien @ 2012-11-13 22:02 UTC (permalink / raw)
To: Ivan Vilata i Balaguer; +Cc: emacs-orgmode
Hi Ivan,
Ivan Vilata i Balaguer <ivan@selidor.net> writes:
> However, I'm looking at the Git master branch and I see that the patch
> hasn't actually been applied [there][1] yet (and the [original
> thread][2] is from March). Is there any problem with it? Am I looking
> at the wrong repo?
>
> [1]: http://orgmode.org/cgit.cgi/org-mode.git/tree/lisp/org.el#n16359
> [2]: http://comments.gmane.org/gmane.emacs.orgmode/54101
I'm not sure what went wrong on your side but the patch
has been applied here:
http://orgmode.org/cgit.cgi/org-mode.git/commit/?id=001bcb9645bf0a5ea72f09ae502a8410319473c0
HTH,
--
Bastien
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] Time specifications: Allow specifying relative times
2012-11-13 22:02 ` Bastien
@ 2012-11-14 0:07 ` Ivan Vilata i Balaguer
2012-11-14 19:44 ` Achim Gratz
0 siblings, 1 reply; 9+ messages in thread
From: Ivan Vilata i Balaguer @ 2012-11-14 0:07 UTC (permalink / raw)
To: emacs-orgmode
Bastien (2012-11-13 23:02:40 +0100) wrote:
> Ivan Vilata i Balaguer <ivan@selidor.net> writes:
>
>> However, I'm looking at the Git master branch and I see that the
>> patch hasn't actually been applied [there][1] yet (and the [original
>> thread][2] is from March). Is there any problem with it? Am I
>> looking at the wrong repo?
>>
>> [1]: http://orgmode.org/cgit.cgi/org-mode.git/tree/lisp/org.el#n16359
>> [2]: http://comments.gmane.org/gmane.emacs.orgmode/54101
>
> I'm not sure what went wrong on your side but the patch
> has been applied here:
>
> http://orgmode.org/cgit.cgi/org-mode.git/commit/?id=001bcb9645bf0a5ea72f09ae502a8410319473c0
Sure I can see the patch, but then how come the version of
``org-parse-time-string`` in the head of both the master and maint
branches is still the one from before the patch was applied? It's quite
strange...
I apologise if I'm getting confused with git or the way the Org repo is
structured, but maybe the change was accidentally reverted later.
In any case, thanks for your answer!
--
Ivan Vilata i Balaguer -- https://elvil.net/
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] Time specifications: Allow specifying relative times
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
0 siblings, 1 reply; 9+ messages in thread
From: Achim Gratz @ 2012-11-14 19:44 UTC (permalink / raw)
To: emacs-orgmode
Ivan Vilata i Balaguer writes:
> Bastien (2012-11-13 23:02:40 +0100) wrote:
>> I'm not sure what went wrong on your side but the patch
>> has been applied here:
>>
>> http://orgmode.org/cgit.cgi/org-mode.git/commit/?id=001bcb9645bf0a5ea72f09ae502a8410319473c0
>
> I apologise if I'm getting confused with git or the way the Org repo is
> structured, but maybe the change was accidentally reverted later.
It was reverted with 6f78edd68c, two hours after having been applied.
Regards,
Achim.
--
+<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+
Samples for the Waldorf Blofeld:
http://Synth.Stromeko.net/Downloads.html#BlofeldSamplesExtra
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] Time specifications: Allow specifying relative times
2012-11-14 19:44 ` Achim Gratz
@ 2012-11-14 22:53 ` Ivan Vilata i Balaguer
2012-12-30 9:28 ` Bastien
0 siblings, 1 reply; 9+ messages in thread
From: Ivan Vilata i Balaguer @ 2012-11-14 22:53 UTC (permalink / raw)
To: emacs-orgmode
Achim Gratz (2012-11-14 20:44:55 +0100) wrote:
> Ivan Vilata i Balaguer writes:
>> Bastien (2012-11-13 23:02:40 +0100) wrote:
>>> I'm not sure what went wrong on your side but the patch
>>> has been applied here:
>>>
>>> http://orgmode.org/cgit.cgi/org-mode.git/commit/?id=001bcb9645bf0a5ea72f09ae502a8410319473c0
>>
>> I apologise if I'm getting confused with git or the way the Org repo
>> is structured, but maybe the change was accidentally reverted later.
>
> It was reverted with 6f78edd68c, two hours after having been applied.
So the relative time specifications patch caused some kind of problem?
That'd be a real shame, the feature could be very useful. :(
Thanks for the info,
--
Ivan Vilata i Balaguer -- https://elvil.net/
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] Time specifications: Allow specifying relative times
2012-11-14 22:53 ` Ivan Vilata i Balaguer
@ 2012-12-30 9:28 ` Bastien
0 siblings, 0 replies; 9+ messages in thread
From: Bastien @ 2012-12-30 9:28 UTC (permalink / raw)
To: Ivan Vilata i Balaguer; +Cc: emacs-orgmode
Hi Ivan,
Ivan Vilata i Balaguer <ivan@selidor.net> writes:
> So the relative time specifications patch caused some kind of problem?
Yes. The problem was that inactive time-stamps were not correctly
parsed anymore.
> That'd be a real shame, the feature could be very useful. :(
I just applied an updated patch to master which brings this useful
feature back.
Best,
--
Bastien
^ permalink raw reply [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).