emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Clock time implied as 00:00
@ 2011-12-29 16:57 François Pinard
  2011-12-29 19:47 ` Nick Dokos
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: François Pinard @ 2011-12-29 16:57 UTC (permalink / raw)
  To: emacs-orgmode

Hi, Org people.

This morning, I just noticed this line:

CLOCK: [2011-12-29 jeu 9:30]--[2011-12-29 jeu 11:44] => 11:44

because of the strange 11:44 total.  My error is clear, as I wrote 9:30
instead of 09:30.  Correcting it gives a move reasonable total:

CLOCK: [2011-12-29 jeu 09:30]--[2011-12-29 jeu 11:44] =>  2:14

Yet, forgetting a leading 0 is an easy mistake (I know I should not make
mistakes!), and then, maybe (I'm not sure) Org mode could deliver
unexpected or misleading statistics out of a silent error.  Not such a
problem for me, yet it could have become one if I missed it.

Would it be reasonable to suggest that Org mode be more lenient about
missing leading zeroes?

François

P.S. I wish every one is enjoying the Festive Times!

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

* Re: Clock time implied as 00:00
  2011-12-29 16:57 Clock time implied as 00:00 François Pinard
@ 2011-12-29 19:47 ` Nick Dokos
  2011-12-30 22:27 ` Nick Dokos
  2011-12-31 17:01 ` Bastien
  2 siblings, 0 replies; 5+ messages in thread
From: Nick Dokos @ 2011-12-29 19:47 UTC (permalink / raw)
  To: =?utf-8?Q?Fran=C3=A7ois?= Pinard; +Cc: nicholas.dokos, emacs-orgmode

François Pinard <pinard@iro.umontreal.ca> wrote:

> Hi, Org people.
> 
> This morning, I just noticed this line:
> 
> CLOCK: [2011-12-29 jeu 9:30]--[2011-12-29 jeu 11:44] => 11:44
> 
> because of the strange 11:44 total.  My error is clear, as I wrote 9:30
> instead of 09:30.  Correcting it gives a move reasonable total:
> 
> CLOCK: [2011-12-29 jeu 09:30]--[2011-12-29 jeu 11:44] =>  2:14
> 
> Yet, forgetting a leading 0 is an easy mistake (I know I should not make
> mistakes!), and then, maybe (I'm not sure) Org mode could deliver
> unexpected or misleading statistics out of a silent error.  Not such a
> problem for me, yet it could have become one if I missed it.
> 
> Would it be reasonable to suggest that Org mode be more lenient about
> missing leading zeroes?
> 

IMO, yes. This looks like a bug in org-parse-time-string which is supposed
to be an optimized parse-time-string, but look:

,----
| (setq ts "2011-12-29 Thu 2:11")
| "2011-12-29 Thu 2:11"
| 
| (parse-time-string ts)
| (0 11 2 29 12 2011 4 nil nil)
| (org-parse-time-string ts)
| (0 0 0 29 12 2011 nil nil nil)
`----

Nick

> François
> 
> P.S. I wish every one is enjoying the Festive Times!
> 
> 

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

* Re: Clock time implied as 00:00
  2011-12-29 16:57 Clock time implied as 00:00 François Pinard
  2011-12-29 19:47 ` Nick Dokos
@ 2011-12-30 22:27 ` Nick Dokos
  2011-12-31  8:42   ` Bastien
  2011-12-31 17:01 ` Bastien
  2 siblings, 1 reply; 5+ messages in thread
From: Nick Dokos @ 2011-12-30 22:27 UTC (permalink / raw)
  To: =?utf-8?Q?Fran=C3=A7ois?= Pinard; +Cc: nicholas.dokos, emacs-orgmode

François Pinard <pinard@iro.umontreal.ca> wrote:

> Hi, Org people.
> 
> This morning, I just noticed this line:
> 
> CLOCK: [2011-12-29 jeu 9:30]--[2011-12-29 jeu 11:44] => 11:44
> 
> because of the strange 11:44 total.  My error is clear, as I wrote 9:30
> instead of 09:30.  Correcting it gives a move reasonable total:
> 
> CLOCK: [2011-12-29 jeu 09:30]--[2011-12-29 jeu 11:44] =>  2:14
> 
> Yet, forgetting a leading 0 is an easy mistake (I know I should not make
> mistakes!), and then, maybe (I'm not sure) Org mode could deliver
> unexpected or misleading statistics out of a silent error.  Not such a
> problem for me, yet it could have become one if I missed it.
> 
> Would it be reasonable to suggest that Org mode be more lenient about
> missing leading zeroes?
> 

There are two regexps that match timestamps, org-ts-regexp0 and
org-ts-regexp1 (and two more, derived from the first two). In each case
the part that matches the HH:MM part is as follows:

"... \\([0-9]\\{2\\}\\):\\([0-9]\\{2\\}\\)..."

in words: "exactly two digits, followed by a colon, followed by exactly
two digits".  Modifying them so that the HH part can be "one or two
digits" seems to make org-parse-time-string work correctly with the above
input:

"... \\([0-9]\\{1,2\\}\\):\\([0-9]\\{2\\}\\)..."

Whether this has undesirable consequences[fn:1], I don't know. Actually
it's only regexp0 that is used in org-parse-time-string, so strictly
speaking, only it needs to be modified.

Nick

Footnotes:

[fn:1] In particular, org-ts-regexp0 is explicitly used in org-odt.el, so at least that part
       needs to be checked for breakage, something that I have not done.

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

* Re: Clock time implied as 00:00
  2011-12-30 22:27 ` Nick Dokos
@ 2011-12-31  8:42   ` Bastien
  0 siblings, 0 replies; 5+ messages in thread
From: Bastien @ 2011-12-31  8:42 UTC (permalink / raw)
  To: nicholas.dokos; +Cc: =?utf-8?Q?Fran=C3=A7ois?= Pinard, emacs-orgmode

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

Hi François and Nick,

I have tested this small patch, implementing Nick's solution.
No breakage on my side -- but let's be careful here.

Thanks for testing,


[-- Attachment #2: 0001-Be-a-bit-more-flexible-when-matching-time-values-in-.patch --]
[-- Type: text/x-patch, Size: 2000 bytes --]

From 6b2fbed71355f5b37b723e15e7aad20fb4ce3f07 Mon Sep 17 00:00:00 2001
From: Bastien Guerry <bzg@altern.org>
Date: Sat, 31 Dec 2011 09:39:58 +0100
Subject: [PATCH] Be a bit more flexible when matching time values in
 timestamps.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* org.el (org-ts-regexp0, org-ts-regexp1): Also match a time
value with only one digit for the hours.

Thanks to François Pinard for mentioning this.
---
 lisp/org.el |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index 61ca072..882e349 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -5214,11 +5214,11 @@ This should be called after the variable `org-link-types' has changed."
   "Regular expression for fast time stamp matching.")
 (defconst org-ts-regexp-both "[[<]\\([0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\} ?[^]\r\n>]*?\\)[]>]"
   "Regular expression for fast time stamp matching.")
-(defconst org-ts-regexp0 "\\(\\([0-9]\\{4\\}\\)-\\([0-9]\\{2\\}\\)-\\([0-9]\\{2\\}\\) *\\([^]+0-9>\r\n -]*\\)\\( \\([0-9]\\{2\\}\\):\\([0-9]\\{2\\}\\)\\)?\\)"
+(defconst org-ts-regexp0 "\\(\\([0-9]\\{4\\}\\)-\\([0-9]\\{2\\}\\)-\\([0-9]\\{2\\}\\) *\\([^]+0-9>\r\n -]*\\)\\( \\([0-9]\\{1,2\\}\\):\\([0-9]\\{2\\}\\)\\)?\\)"
   "Regular expression matching time strings for analysis.
 This one does not require the space after the date, so it can be used
 on a string that terminates immediately after the date.")
-(defconst org-ts-regexp1 "\\(\\([0-9]\\{4\\}\\)-\\([0-9]\\{2\\}\\)-\\([0-9]\\{2\\}\\) *\\([^]+0-9>\r\n -]*\\)\\( \\([0-9]\\{2\\}\\):\\([0-9]\\{2\\}\\)\\)?\\)"
+(defconst org-ts-regexp1 "\\(\\([0-9]\\{4\\}\\)-\\([0-9]\\{2\\}\\)-\\([0-9]\\{2\\}\\) *\\([^]+0-9>\r\n -]*\\)\\( \\([0-9]\\{1,2\\}\\):\\([0-9]\\{2\\}\\)\\)?\\)"
   "Regular expression matching time strings for analysis.")
 (defconst org-ts-regexp2 (concat "<" org-ts-regexp1 "[^>\n]\\{0,16\\}>")
   "Regular expression matching time stamps, with groups.")
-- 
1.7.8.1


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


-- 
 Bastien

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

* Re: Clock time implied as 00:00
  2011-12-29 16:57 Clock time implied as 00:00 François Pinard
  2011-12-29 19:47 ` Nick Dokos
  2011-12-30 22:27 ` Nick Dokos
@ 2011-12-31 17:01 ` Bastien
  2 siblings, 0 replies; 5+ messages in thread
From: Bastien @ 2011-12-31 17:01 UTC (permalink / raw)
  To: François Pinard; +Cc: emacs-orgmode

Hi François,

pinard@iro.umontreal.ca (François Pinard) writes:

> This morning, I just noticed this line:
>
> CLOCK: [2011-12-29 jeu 9:30]--[2011-12-29 jeu 11:44] => 11:44

This should be fixed now, thanks for reporting this.

Best,

-- 
 Bastien

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

end of thread, other threads:[~2011-12-31 17:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-12-29 16:57 Clock time implied as 00:00 François Pinard
2011-12-29 19:47 ` Nick Dokos
2011-12-30 22:27 ` Nick Dokos
2011-12-31  8:42   ` Bastien
2011-12-31 17:01 ` Bastien

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).