From: Jan Malakhovski <oxij@oxij.org>
To: emacs-orgmode@gnu.org
Cc: Jan Malakhovski <oxij@oxij.org>
Subject: [PATCH 3/9] org-clock: fix `org-clock-time%'
Date: Tue, 3 Nov 2015 20:15:41 +0000 [thread overview]
Message-ID: <1446581747-1960-4-git-send-email-oxij@oxij.org> (raw)
In-Reply-To: <1446581747-1960-1-git-send-email-oxij@oxij.org>
* lisp/org-clock.el (org-clock-time%): Respect org-effort-durations.
This also fixes a bug with time percents looking pretty much random and adding
to a number that is less than 100% when a clock report has long intervals
(e.g. days).
---
lisp/org-clock.el | 29 +++++++++++------------------
1 file changed, 11 insertions(+), 18 deletions(-)
diff --git a/lisp/org-clock.el b/lisp/org-clock.el
index ad423f1..4563a8a 100644
--- a/lisp/org-clock.el
+++ b/lisp/org-clock.el
@@ -2867,27 +2867,20 @@ TIME: The sum of all time spend in this tree, in minutes. This time
(defun org-clock-time% (total &rest strings)
"Compute a time fraction in percent.
-TOTAL s a time string like 10:21 specifying the total times.
+TOTAL s a total time string.
STRINGS is a list of strings that should be checked for a time.
-The first string that does have a time will be used.
-This function is made for clock tables."
- (let ((re "\\([0-9]+\\):\\([0-9]+\\)")
- tot s)
- (save-match-data
+Strings are parsed using `org-duration-string-to-minutes`.
+The first string that does have a time will be used. This
+function is made for clock tables."
+ (save-match-data
+ (let (tot s cur)
(catch 'exit
- (if (not (string-match re total))
- (throw 'exit 0.)
- (setq tot (+ (string-to-number (match-string 2 total))
- (* 60 (string-to-number (match-string 1 total)))))
- (if (= tot 0.) (throw 'exit 0.)))
+ (setq tot (org-duration-string-to-minutes total))
+ (if (= tot 0.) (throw 'exit 0.))
(while (setq s (pop strings))
- (if (string-match "\\([0-9]+\\):\\([0-9]+\\)" s)
- (throw 'exit
- (/ (* 100.0 (+ (string-to-number (match-string 2 s))
- (* 60 (string-to-number
- (match-string 1 s)))))
- tot))))
- 0))))
+ (setq cur (org-clocksum-string-to-minutes s))
+ (if (not (equal cur nil)) (throw 'exit (/ (* 100.0 cur) tot))))
+ nil))))
;; Saving and loading the clock
--
2.6.2
next prev parent reply other threads:[~2015-11-03 20:16 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-03 20:15 [PATCH v2 0/9] mail, clock and calc changes Jan Malakhovski
2015-11-03 20:15 ` [PATCH 1/9] org-clock: fix a typo Jan Malakhovski
2015-11-03 20:15 ` [PATCH 2/9] org-colview: add a FIXME Jan Malakhovski
2015-11-03 20:15 ` Jan Malakhovski [this message]
2015-11-04 11:18 ` [PATCH 3/9] org-clock: fix `org-clock-time%' Aaron Ecay
2015-11-04 11:46 ` Jan Malakhovski
2015-11-03 20:15 ` [PATCH 4/9] org: move `org-duration-string-to-minutes' to a better place Jan Malakhovski
2015-11-03 20:15 ` [PATCH 5/9] rename `org-duration-string-to-minutes' to `org-clocksum-string-to-minutes' everywhere Jan Malakhovski
2015-11-04 11:21 ` Aaron Ecay
2015-11-04 11:47 ` Jan Malakhovski
2015-11-03 20:15 ` [PATCH 6/9] factor out date-timestamp* calculations to org-store-link-props Jan Malakhovski
2015-11-04 11:26 ` Aaron Ecay
2015-11-04 11:45 ` Jan Malakhovski
2015-11-04 14:39 ` Aaron Ecay
2015-11-04 15:21 ` Jan Malakhovski
2015-11-03 20:15 ` [PATCH 7/9] org-notmuch: add date support to org-notmuch-store-link Jan Malakhovski
2015-11-03 20:15 ` [PATCH 8/9] ob-calc: add more API, documentation and examples so that it can be used in tables Jan Malakhovski
2015-11-03 20:15 ` [PATCH 9/9] ob-calc: don't leave garbage on the stack Jan Malakhovski
2015-11-04 11:31 ` Aaron Ecay
2015-11-04 11:53 ` Jan Malakhovski
2015-11-04 14:41 ` Aaron Ecay
2015-11-04 15:24 ` Jan Malakhovski
2015-11-04 11:36 ` [PATCH v2 0/9] mail, clock and calc changes Aaron Ecay
2015-11-04 11:59 ` Jan Malakhovski
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=1446581747-1960-4-git-send-email-oxij@oxij.org \
--to=oxij@oxij.org \
--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).