* [PATCH] org-agenda: simplify start/stop/duration time computing
@ 2010-12-22 16:55 Julien Danjou
2011-01-26 10:16 ` [Accepted] " Carsten Dominik
0 siblings, 1 reply; 2+ messages in thread
From: Julien Danjou @ 2010-12-22 16:55 UTC (permalink / raw)
To: emacs-orgmode; +Cc: Julien Danjou
* org-agenda.el (org-format-agenda-item): Simplify time comuting.
Signed-off-by: Julien Danjou <julien@danjou.info>
---
lisp/org-agenda.el | 31 +++++++++++--------------------
1 files changed, 11 insertions(+), 20 deletions(-)
diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index 1cdaaa0..8f597f5 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -5165,7 +5165,7 @@ Any match of REMOVE-RE will be removed from TXT."
(if (stringp dotime) dotime "")
(and org-agenda-search-headline-for-time txt))))
(time-of-day (and dotime (org-get-time-of-day ts)))
- stamp plain s0 s1 s2 t1 t2 rtn srp l
+ stamp plain s0 s1 s2 rtn srp l
duration thecategory)
(and (org-mode-p) buffer-file-name
(add-to-list 'org-agenda-contributing-files buffer-file-name))
@@ -5192,26 +5192,17 @@ Any match of REMOVE-RE will be removed from TXT."
;; Normalize the time(s) to 24 hour
(if s1 (setq s1 (org-get-time-of-day s1 'string t)))
(if s2 (setq s2 (org-get-time-of-day s2 'string t)))
+
+ ;; Try to set s2 if s1 and `org-agenda-default-appointment-duration' are set
+ (when (and s1 (not s2) org-agenda-default-appointment-duration)
+ (setq s2
+ (org-minutes-to-hh:mm-string
+ (+ (org-hh:mm-string-to-minutes s1) org-agenda-default-appointment-duration))))
+
;; Compute the duration
- (when s1
- (setq t1 (+ (* 60 (string-to-number (substring s1 0 2)))
- (string-to-number (substring s1 3)))
- t2 (cond
- (s2 (+ (* 60 (string-to-number (substring s2 0 2)))
- (string-to-number (substring s2 3))))
- (org-agenda-default-appointment-duration
- (+ t1 org-agenda-default-appointment-duration))
- (t nil)))
- (setq duration (if t2 (- t2 t1)))))
-
- (when (and s1 (not s2) org-agenda-default-appointment-duration
- (string-match "\\([0-9]+\\):\\([0-9]+\\)" s1))
- (let ((m (+ (string-to-number (match-string 2 s1))
- (* 60 (string-to-number (match-string 1 s1)))
- org-agenda-default-appointment-duration))
- h)
- (setq h (/ m 60) m (- m (* h 60)))
- (setq s2 (format "%02d:%02d" h m))))
+ (when s2
+ (setq duration (- (org-hh:mm-string-to-minutes s2)
+ (org-hh:mm-string-to-minutes s1)))))
(when (string-match (org-re "\\([ \t]+\\)\\(:[[:alnum:]_@#%:]+:\\)[ \t]*$")
txt)
--
1.7.2.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [Accepted] org-agenda: simplify start/stop/duration time computing
2010-12-22 16:55 [PATCH] org-agenda: simplify start/stop/duration time computing Julien Danjou
@ 2011-01-26 10:16 ` Carsten Dominik
0 siblings, 0 replies; 2+ messages in thread
From: Carsten Dominik @ 2011-01-26 10:16 UTC (permalink / raw)
To: emacs-orgmode
Patch 506 (http://patchwork.newartisans.com/patch/506/) is now "Accepted".
Maintainer comment: none
This relates to the following submission:
http://mid.gmane.org/%3C1293036946-14552-1-git-send-email-julien%40danjou.info%3E
Here is the original message containing the patch:
> Content-Type: text/plain; charset="utf-8"
> MIME-Version: 1.0
> Content-Transfer-Encoding: 7bit
> Subject: [Orgmode] org-agenda: simplify start/stop/duration time computing
> Date: Wed, 22 Dec 2010 21:55:46 -0000
> From: Julien Danjou <julien@danjou.info>
> X-Patchwork-Id: 506
> Message-Id: <1293036946-14552-1-git-send-email-julien@danjou.info>
> To: emacs-orgmode@gnu.org
> Cc: Julien Danjou <julien@danjou.info>
>
> * org-agenda.el (org-format-agenda-item): Simplify time comuting.
>
> Signed-off-by: Julien Danjou <julien@danjou.info>
>
> ---
> lisp/org-agenda.el | 31 +++++++++++--------------------
> 1 files changed, 11 insertions(+), 20 deletions(-)
>
> diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
> index 1cdaaa0..8f597f5 100644
> --- a/lisp/org-agenda.el
> +++ b/lisp/org-agenda.el
> @@ -5165,7 +5165,7 @@ Any match of REMOVE-RE will be removed from TXT."
> (if (stringp dotime) dotime "")
> (and org-agenda-search-headline-for-time txt))))
> (time-of-day (and dotime (org-get-time-of-day ts)))
> - stamp plain s0 s1 s2 t1 t2 rtn srp l
> + stamp plain s0 s1 s2 rtn srp l
> duration thecategory)
> (and (org-mode-p) buffer-file-name
> (add-to-list 'org-agenda-contributing-files buffer-file-name))
> @@ -5192,26 +5192,17 @@ Any match of REMOVE-RE will be removed from TXT."
> ;; Normalize the time(s) to 24 hour
> (if s1 (setq s1 (org-get-time-of-day s1 'string t)))
> (if s2 (setq s2 (org-get-time-of-day s2 'string t)))
> +
> + ;; Try to set s2 if s1 and `org-agenda-default-appointment-duration' are set
> + (when (and s1 (not s2) org-agenda-default-appointment-duration)
> + (setq s2
> + (org-minutes-to-hh:mm-string
> + (+ (org-hh:mm-string-to-minutes s1) org-agenda-default-appointment-duration))))
> +
> ;; Compute the duration
> - (when s1
> - (setq t1 (+ (* 60 (string-to-number (substring s1 0 2)))
> - (string-to-number (substring s1 3)))
> - t2 (cond
> - (s2 (+ (* 60 (string-to-number (substring s2 0 2)))
> - (string-to-number (substring s2 3))))
> - (org-agenda-default-appointment-duration
> - (+ t1 org-agenda-default-appointment-duration))
> - (t nil)))
> - (setq duration (if t2 (- t2 t1)))))
> -
> - (when (and s1 (not s2) org-agenda-default-appointment-duration
> - (string-match "\\([0-9]+\\):\\([0-9]+\\)" s1))
> - (let ((m (+ (string-to-number (match-string 2 s1))
> - (* 60 (string-to-number (match-string 1 s1)))
> - org-agenda-default-appointment-duration))
> - h)
> - (setq h (/ m 60) m (- m (* h 60)))
> - (setq s2 (format "%02d:%02d" h m))))
> + (when s2
> + (setq duration (- (org-hh:mm-string-to-minutes s2)
> + (org-hh:mm-string-to-minutes s1)))))
>
> (when (string-match (org-re "\\([ \t]+\\)\\(:[[:alnum:]_@#%:]+:\\)[ \t]*$")
> txt)
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-01-26 10:16 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-12-22 16:55 [PATCH] org-agenda: simplify start/stop/duration time computing Julien Danjou
2011-01-26 10:16 ` [Accepted] " Carsten Dominik
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).