emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "Chris Leyon" <cleyon@gmail.com>
To: emacs-orgmode@gnu.org
Subject: Re: Computed negative CLOCK time 1 hour off
Date: Thu, 16 Oct 2008 22:03:15 -0400	[thread overview]
Message-ID: <5ea706d0810161903g5d8edc68xfd6fa02f7ef95c6b@mail.gmail.com> (raw)
In-Reply-To: <7355589A-8AF4-44C9-BD0E-454D4838C90F@uva.nl>

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

There is a precedent in the Emacs manual -- Appendix E, Antinews: "For
those users who live backwards in time [...]"

:-)

I admit there may not be great practical utility in a negative time
range.  But the interval is well-defined so it ought to be computed
correctly.  I would say that a wrong answer is worse than no answer
since it may be believed correct at first glance, when it is not.

Anyway, I'm including a patch for 6.09 which seems to fix the problem....

On Thu, Oct 16, 2008 at 12:39 PM, Carsten Dominik
<dominik@science.uva.nl> wrote:
> Hi Chris,
>
> what could possibly be the purpose of a negative time range?  Are you
> working for a secret government agency?
>
> :-)
>
> - Carsten

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: neg-time.patch --]
[-- Type: text/x-patch; name=neg-time.patch, Size: 635 bytes --]

--- /home/cleyon/u/share/emacs/site-lisp/org-6.09/lisp/org.el	2008-10-09 10:25:12.000000000 -0400
+++ org.el	2008-10-16 21:57:45.000000000 -0400
@@ -2511,11 +2511,12 @@
 		      (apply 'encode-time (org-parse-time-string te)))
 		     (time-to-seconds
 		      (apply 'encode-time (org-parse-time-string ts))))
-		h (floor (/ s 3600))
+		sign (if (< s 0) "-" "")
+		h (truncate (/ s 3600))
 		s (- s (* 3600 h))
-		m (floor (/ s 60))
+		m (truncate (/ s 60))
 		s (- s (* 60 s)))
-	  (insert " => " (format "%2d:%02d" h m))
+	  (insert " => " (format "%s%d:%02d" sign (abs h) (abs m)))
 	  t))))))
 
 (defun org-check-running-clock ()

[-- Attachment #3: Type: text/plain, Size: 204 bytes --]

_______________________________________________
Emacs-orgmode mailing list
Remember: use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

  reply	other threads:[~2008-10-17  2:03 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-16 15:24 Computed negative CLOCK time 1 hour off Chris Leyon
2008-10-16 16:39 ` Carsten Dominik
2008-10-17  2:03   ` Chris Leyon [this message]
2008-10-17  5:27     ` Carsten Dominik

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=5ea706d0810161903g5d8edc68xfd6fa02f7ef95c6b@mail.gmail.com \
    --to=cleyon@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).