emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] Fix incorrect time calculation for org-extend-today-until
@ 2013-09-15 16:37 Ian Kelling
  2013-09-15 17:04 ` Ian Kelling
  2013-10-16 18:58 ` Ian Kelling
  0 siblings, 2 replies; 4+ messages in thread
From: Ian Kelling @ 2013-09-15 16:37 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 819 bytes --]

During the extra hours of org-extend-today-until, when
org-clock-mode-line-total is 'today, the clocked time shown in the
modeline is wrong. It ignores all previously clocked time, when it
should add them starting from the past day beyond
org-extend-today-until hours.  This also affects clock tables.

The problem can be reproduced in emacs with the following code,
as long as the current time is not between 11 PM and 12 AM:

   (progn
     (require 'org-clock)
     (setq org-clock-mode-line-total 'today)
     (setq org-extend-today-until 23)
     (format-time-string "%a %D %l:%M %p" (org-clock-get-sum-start)))

expected result:
A date of yesterday, time of 11:00 PM

Actual result:
A date of today, time of 11:00 PM

Note this patch only fixes a bug where org-extend-today-until
is already used.


- Ian Kelling

[-- Attachment #2: 0001-Fix-incorrect-time-calculation-for-org-extend-today-.patch --]
[-- Type: text/x-patch, Size: 1224 bytes --]

From 619572e221cafc17f0a1c33654eb22d7ca5f4d89 Mon Sep 17 00:00:00 2001
From: Ian Kelling <ianowl@gmail.com>
Date: Sun, 15 Sep 2013 08:03:24 -0700
Subject: [PATCH] Fix incorrect time calculation for org-extend-today-until

* lisp/org-clock.el Fix bad date math. Affects mode line and
  clock tables.

TINYCHANGE
---
 lisp/org-clock.el | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/lisp/org-clock.el b/lisp/org-clock.el
index 9f22562..3195dc1 100644
--- a/lisp/org-clock.el
+++ b/lisp/org-clock.el
@@ -1368,10 +1368,12 @@ decides which time to use."
       (current-time))
      ((equal cmt "today")
       (setq msg-extra "showing today's task time.")
-      (let* ((dt (decode-time (current-time))))
-	(setq dt (append (list 0 0 0) (nthcdr 3 dt)))
-	(if org-extend-today-until
-	    (setf (nth 2 dt) org-extend-today-until))
+      (let* ((dt (decode-time (current-time)))
+	     (hour (nth 2 dt))
+	     (day (nth 3 dt)))
+	(if (< hour org-extend-today-until) (setf (nth 3 dt) (1- day)))
+	(setf (nth 2 dt) org-extend-today-until)
+	(setq dt (append (list 0 0) (nthcdr 2 dt)))
 	(apply 'encode-time dt)))
      ((or (equal cmt "all")
 	  (and (or (not cmt) (equal cmt "auto"))
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] Fix incorrect time calculation for org-extend-today-until
  2013-09-15 16:37 [PATCH] Fix incorrect time calculation for org-extend-today-until Ian Kelling
@ 2013-09-15 17:04 ` Ian Kelling
  2013-10-16 18:58 ` Ian Kelling
  1 sibling, 0 replies; 4+ messages in thread
From: Ian Kelling @ 2013-09-15 17:04 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 44 bytes --]

Updated patch, fixed commit message format.

[-- Attachment #2: 0001-Fix-incorrect-time-calculation-for-org-extend-today-.patch --]
[-- Type: text/x-patch, Size: 1255 bytes --]

From 0c23ccb9b00fd42f830f5a7472e2980b93c6040f Mon Sep 17 00:00:00 2001
From: Ian Kelling <ianowl@gmail.com>
Date: Sun, 15 Sep 2013 08:03:24 -0700
Subject: [PATCH] Fix incorrect time calculation for `org-extend-today-until'

* lisp/org-clock.el (org-clock-get-sum-start): Fix bad date
  math, affecting mode line and clock tables.

TINYCHANGE
---
 lisp/org-clock.el | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/lisp/org-clock.el b/lisp/org-clock.el
index 9f22562..3195dc1 100644
--- a/lisp/org-clock.el
+++ b/lisp/org-clock.el
@@ -1368,10 +1368,12 @@ decides which time to use."
       (current-time))
      ((equal cmt "today")
       (setq msg-extra "showing today's task time.")
-      (let* ((dt (decode-time (current-time))))
-	(setq dt (append (list 0 0 0) (nthcdr 3 dt)))
-	(if org-extend-today-until
-	    (setf (nth 2 dt) org-extend-today-until))
+      (let* ((dt (decode-time (current-time)))
+	     (hour (nth 2 dt))
+	     (day (nth 3 dt)))
+	(if (< hour org-extend-today-until) (setf (nth 3 dt) (1- day)))
+	(setf (nth 2 dt) org-extend-today-until)
+	(setq dt (append (list 0 0) (nthcdr 2 dt)))
 	(apply 'encode-time dt)))
      ((or (equal cmt "all")
 	  (and (or (not cmt) (equal cmt "auto"))
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH] Fix incorrect time calculation for org-extend-today-until
  2013-09-15 16:37 [PATCH] Fix incorrect time calculation for org-extend-today-until Ian Kelling
  2013-09-15 17:04 ` Ian Kelling
@ 2013-10-16 18:58 ` Ian Kelling
  2013-10-17  5:42   ` Carsten Dominik
  1 sibling, 1 reply; 4+ messages in thread
From: Ian Kelling @ 2013-10-16 18:58 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 939 bytes --]

I sent this patch a month ago, but it got no reply. Perhaps that I
accidentally had html email format didn't help.

During the extra hours of org-extend-today-until, when
org-clock-mode-line-total is 'today, the clocked time shown in the
modeline is wrong. It ignores all previously clocked time, when it
should add them starting from the past day beyond
org-extend-today-until hours.  This also affects clock tables.

The problem can be reproduced in emacs -q with the following code,
as long as the current time is not between 11 PM and 12 AM:

   (progn
     (require 'org-clock)
     (setq org-clock-mode-line-total 'today)
     (setq org-extend-today-until 23)
     (format-time-string "%a %D %l:%M %p" (org-clock-get-sum-start)))

expected result:
A date of yesterday, time of 11:00 PM

Actual result:
A date of today, time of 11:00 PM

Note this patch only fixes a bug where org-extend-today-until
is already used.


- Ian Kelling


[-- Attachment #2: 0001-Fix-incorrect-time-calculation-for-org-extend-today-.patch --]
[-- Type: text/x-patch, Size: 1256 bytes --]

From 0c23ccb9b00fd42f830f5a7472e2980b93c6040f Mon Sep 17 00:00:00 2001
From: Ian Kelling <ianowl@gmail.com>
Date: Sun, 15 Sep 2013 08:03:24 -0700
Subject: [PATCH] Fix incorrect time calculation for `org-extend-today-until'

* lisp/org-clock.el (org-clock-get-sum-start): Fix bad date
  math, affecting mode line and clock tables.

TINYCHANGE
---
 lisp/org-clock.el | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/lisp/org-clock.el b/lisp/org-clock.el
index 9f22562..3195dc1 100644
--- a/lisp/org-clock.el
+++ b/lisp/org-clock.el
@@ -1368,10 +1368,12 @@ decides which time to use."
       (current-time))
      ((equal cmt "today")
       (setq msg-extra "showing today's task time.")
-      (let* ((dt (decode-time (current-time))))
-	(setq dt (append (list 0 0 0) (nthcdr 3 dt)))
-	(if org-extend-today-until
-	    (setf (nth 2 dt) org-extend-today-until))
+      (let* ((dt (decode-time (current-time)))
+	     (hour (nth 2 dt))
+	     (day (nth 3 dt)))
+	(if (< hour org-extend-today-until) (setf (nth 3 dt) (1- day)))
+	(setf (nth 2 dt) org-extend-today-until)
+	(setq dt (append (list 0 0) (nthcdr 2 dt)))
 	(apply 'encode-time dt)))
      ((or (equal cmt "all")
 	  (and (or (not cmt) (equal cmt "auto"))
-- 
1.8.3.1



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] Fix incorrect time calculation for org-extend-today-until
  2013-10-16 18:58 ` Ian Kelling
@ 2013-10-17  5:42   ` Carsten Dominik
  0 siblings, 0 replies; 4+ messages in thread
From: Carsten Dominik @ 2013-10-17  5:42 UTC (permalink / raw)
  To: Ian Kelling; +Cc: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 1310 bytes --]

Hi Ian,

I must have missed this a month ago, sorry about this.  I applied the patch now
(by hand, git-am choked on it.)

Thank you!

- Carsten

On 16.10.2013, at 20:58, Ian Kelling <ianowl@gmail.com> wrote:

> I sent this patch a month ago, but it got no reply. Perhaps that I
> accidentally had html email format didn't help.
> 
> During the extra hours of org-extend-today-until, when
> org-clock-mode-line-total is 'today, the clocked time shown in the
> modeline is wrong. It ignores all previously clocked time, when it
> should add them starting from the past day beyond
> org-extend-today-until hours.  This also affects clock tables.
> 
> The problem can be reproduced in emacs -q with the following code,
> as long as the current time is not between 11 PM and 12 AM:
> 
>  (progn
>    (require 'org-clock)
>    (setq org-clock-mode-line-total 'today)
>    (setq org-extend-today-until 23)
>    (format-time-string "%a %D %l:%M %p" (org-clock-get-sum-start)))
> 
> expected result:
> A date of yesterday, time of 11:00 PM
> 
> Actual result:
> A date of today, time of 11:00 PM
> 
> Note this patch only fixes a bug where org-extend-today-until
> is already used.
> 
> 
> - Ian Kelling
> 
> <0001-Fix-incorrect-time-calculation-for-org-extend-today-.patch>


[-- Attachment #2: Message signed with OpenPGP using GPGMail --]
[-- Type: application/pgp-signature, Size: 455 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-10-17  6:05 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-09-15 16:37 [PATCH] Fix incorrect time calculation for org-extend-today-until Ian Kelling
2013-09-15 17:04 ` Ian Kelling
2013-10-16 18:58 ` Ian Kelling
2013-10-17  5:42   ` 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).