From mboxrd@z Thu Jan 1 00:00:00 1970 From: Georgiy Tugai Subject: [PATCH] org-clock: Fix clock report sometimes ignoring hours before :wstart Date: Wed, 4 Oct 2017 21:56:28 +1030 Message-ID: <20171004112628.GE5513@gmail.com> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="+1TulI7fc0PCHNy3" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:38246) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dzhp0-00048I-1X for emacs-orgmode@gnu.org; Wed, 04 Oct 2017 07:26:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dzhow-0002Om-R6 for emacs-orgmode@gnu.org; Wed, 04 Oct 2017 07:26:38 -0400 Received: from mail-it0-x236.google.com ([2607:f8b0:4001:c0b::236]:45622) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dzhow-0002OI-Lv for emacs-orgmode@gnu.org; Wed, 04 Oct 2017 07:26:34 -0400 Received: by mail-it0-x236.google.com with SMTP id x15so15777629itb.0 for ; Wed, 04 Oct 2017 04:26:34 -0700 (PDT) Received: from gmail.com ([101.187.171.220]) by smtp.googlemail.com with ESMTPSA id p187sm7117973itp.26.2017.10.04.04.26.31 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 04 Oct 2017 04:26:32 -0700 (PDT) Content-Disposition: inline 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" To: emacs-org --+1TulI7fc0PCHNy3 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: inline * 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 --+1TulI7fc0PCHNy3 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEt94/pILzkhb5UE6EVMIg1W9Zs5kFAlnUxWQACgkQVMIg1W9Z s5lrVQf/fgR6r8r0pA5IwbNckZBhfonv8NhQzVzcAxjoCi2VJVpa/jdW4fvxIW4H XfeGotWvS0eq0wVBdhXw7bogH8i4tiWYmwVJUmML17m2lIBkz7s9oVXkOUrng+ma 992IMBOsv+onzBP0Vjb7Ag3R5RXWBfhBbd1kmCvQRPLxg+OkrIpGLzdiKs5ZNnXL od4UMvoMb0Jm/NI98m1oxq78IiHWQbBQkfcOjbf4D6vErvANlV9Nr8DLKCuAwUWm wsST82df0BWvJ4XFOa8W33V/B3Xc4f6y2JhXwmajHhZVE+1zrAx6CA0uhtsc3Z0j DWLuK+LopfCGYLXbxQq/aK5DfmSpaw== =WdiT -----END PGP SIGNATURE----- --+1TulI7fc0PCHNy3--