emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Georgiy Tugai <georgiy.tugai@gmail.com>
To: emacs-org <emacs-orgmode@gnu.org>
Subject: [PATCH] org-clock: Fix clock report sometimes ignoring hours before :wstart
Date: Wed, 4 Oct 2017 21:56:28 +1030	[thread overview]
Message-ID: <20171004112628.GE5513@gmail.com> (raw)

[-- Attachment #1: Type: text/x-diff, Size: 2050 bytes --]

* lisp/org-clock (org-clocktable-steps): Fix weekly-step clock report
  ignoring hours between start of period and start of week, when start
  of period is on a day of week numerically less than start of week.

  Clock report now always inserts a "week" starting at the start of
  the period, if necessary; all following weeks start on the start of
  the week as expected.

TINYCHANGE
---
 lisp/org-clock.el | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/lisp/org-clock.el b/lisp/org-clock.el
index 9dc501500..0c899dfa2 100644
--- a/lisp/org-clock.el
+++ b/lisp/org-clock.el
@@ -2725,7 +2725,9 @@ LEVEL is an integer.  Indent by two spaces per level above 1."
       (setq te (float-time (apply #'encode-time (org-parse-time-string te))))))
     (setq tsb
          (if (eq step0 'week)
-             (- ts (* 86400 (- (nth 6 (decode-time (seconds-to-time ts))) ws)))
+             (let ((dow (nth 6 (decode-time (seconds-to-time ts)))))
+		(if (< dow ws) ts
+                 (- ts (* 86400 (- dow ws)))))
            ts))
     (setq p1 (plist-put p1 :header ""))
     (setq p1 (plist-put p1 :step nil))
@@ -2735,9 +2737,12 @@ LEVEL is an integer.  Indent by two spaces per level above 1."
       (setq p1 (plist-put p1 :tstart (format-time-string
                                      (org-time-stamp-format nil t)
                                      (seconds-to-time (max tsb ts)))))
+      (setq tsb (+ tsb (let ((dow (nth 6 (decode-time (seconds-to-time ts)))))
+                        (if (= dow ws) step
+                          (* 86400 (- ws dow))))))
       (setq p1 (plist-put p1 :tend (format-time-string
                                    (org-time-stamp-format nil t)
-                                   (seconds-to-time (min te (setq tsb (+ tsb step)))))))
+                                   (seconds-to-time (min te tsb)))))
       (insert "\n" (if (eq step0 'day) "Daily report: "
                     "Weekly report starting on: ")
              (plist-get p1 :tstart) "\n")
--
2.12.1.windows.1

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

             reply	other threads:[~2017-10-04 11:26 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-04 11:26 Georgiy Tugai [this message]
2017-10-05 14:40 ` [PATCH] org-clock: Fix clock report sometimes ignoring hours before :wstart Nicolas Goaziou
2017-10-07  2:44   ` Georgiy Tugai
2017-10-07  6:44     ` Nicolas Goaziou
2017-10-07 11:31       ` [PATCH v2] " Georgiy Tugai
2017-10-08  8:55         ` Nicolas Goaziou

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=20171004112628.GE5513@gmail.com \
    --to=georgiy.tugai@gmail.com \
    --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).