emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* formatting times as HH:MM with leading zeros
@ 2010-01-20  9:51 Stephen Eglen
  2010-01-20 12:59 ` Matt Lundin
  0 siblings, 1 reply; 7+ messages in thread
From: Stephen Eglen @ 2010-01-20  9:51 UTC (permalink / raw)
  To: emacs-orgmode; +Cc: Stephen Eglen

Just a small suggestion here.  In the agenda, an entry like:
* <2010-01-20 Wed 09:00-09:30> test

gets formatted as follows:

Wednesday  20 January 2010
               8:00...... ----------------
  test:        9:00- 9:30 test
              10:00...... ----------------

the leading whitespace before '9:00' and '9:30' is needed to align the
times, but having the space after the dash looks odd (at least to my
latex-trained eyes).  Would it be possible to patch org-agenda to put a
leading zero rather than leading whitespace.  With this patch, I see:

Wednesday  20 January 2010
              08:00...... ----------------
  test:       09:00-09:30 test
              10:00...... ----------------


diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index a20bec5..77062ed 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -4902,6 +4902,7 @@ HH:MM."
 		    (mod h1 24) h1))
 	    (t0 (+ (* 100 h2) m))
 	    (t1 (concat (if (>= h1 24) "+" " ")
+			(if (< t0 1000) "0" "") ;zero-pad times before 10:00
 			(if (< t0 100) "0" "")
 			(if (< t0 10)  "0" "")
 			(int-to-string t0))))

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

* Re: formatting times as HH:MM with leading zeros
  2010-01-20  9:51 formatting times as HH:MM with leading zeros Stephen Eglen
@ 2010-01-20 12:59 ` Matt Lundin
  2010-01-20 17:29   ` Stephen Eglen
  0 siblings, 1 reply; 7+ messages in thread
From: Matt Lundin @ 2010-01-20 12:59 UTC (permalink / raw)
  To: Stephen Eglen; +Cc: emacs-orgmode

Hi Stephen,

Stephen Eglen <S.J.Eglen@damtp.cam.ac.uk> writes:

> Just a small suggestion here.  In the agenda, an entry like:
> * <2010-01-20 Wed 09:00-09:30> test
>
> gets formatted as follows:
>
> Wednesday  20 January 2010
>                8:00...... ----------------
>   test:        9:00- 9:30 test
>               10:00...... ----------------
>
> the leading whitespace before '9:00' and '9:30' is needed to align the
> times, but having the space after the dash looks odd (at least to my
> latex-trained eyes).  Would it be possible to patch org-agenda to put a
> leading zero rather than leading whitespace.  With this patch, I see:
>
> Wednesday  20 January 2010
>               08:00...... ----------------
>   test:       09:00-09:30 test
>               10:00...... ----------------
>

If I might chime in, I would request that this change be implemented as
an option, not as a default. I greatly prefer the display method as it
stands.

Best,
Matt

>
> diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
> index a20bec5..77062ed 100644
> --- a/lisp/org-agenda.el
> +++ b/lisp/org-agenda.el
> @@ -4902,6 +4902,7 @@ HH:MM."
>  		    (mod h1 24) h1))
>  	    (t0 (+ (* 100 h2) m))
>  	    (t1 (concat (if (>= h1 24) "+" " ")
> +			(if (< t0 1000) "0" "") ;zero-pad times before 10:00
>  			(if (< t0 100) "0" "")
>  			(if (< t0 10)  "0" "")
>  			(int-to-string t0))))
>

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

* Re: formatting times as HH:MM with leading zeros
  2010-01-20 12:59 ` Matt Lundin
@ 2010-01-20 17:29   ` Stephen Eglen
  2010-01-20 19:02     ` Carsten Dominik
  0 siblings, 1 reply; 7+ messages in thread
From: Stephen Eglen @ 2010-01-20 17:29 UTC (permalink / raw)
  To: Matt Lundin; +Cc: emacs-orgmode, Stephen Eglen

> If I might chime in, I would request that this change be implemented as
> an option, not as a default. I greatly prefer the display method as it
> stands.
Dear Matt, certainly -- I can submit a short patch with a variable to
keep the current behaviour as default.

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

* Re: Re: formatting times as HH:MM with leading zeros
  2010-01-20 17:29   ` Stephen Eglen
@ 2010-01-20 19:02     ` Carsten Dominik
  2010-01-20 20:28       ` Stephen Eglen
  0 siblings, 1 reply; 7+ messages in thread
From: Carsten Dominik @ 2010-01-20 19:02 UTC (permalink / raw)
  To: Stephen Eglen; +Cc: Matt Lundin, emacs-orgmode


On Jan 20, 2010, at 6:29 PM, Stephen Eglen wrote:

>> If I might chime in, I would request that this change be  
>> implemented as
>> an option, not as a default. I greatly prefer the display method as  
>> it
>> stands.
> Dear Matt, certainly -- I can submit a short patch with a variable to
> keep the current behaviour as default.

Hi Stephen,

please do, with the current behavior as default.

Thanks!

- Carsten

P.S. I know you have signed some copyright papers.  Do they cover all  
of Emacs?
      Or do we need to take action if you contribute more than very  
small
      patches to Org-mode?

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

* Re: Re: formatting times as HH:MM with leading zeros
  2010-01-20 19:02     ` Carsten Dominik
@ 2010-01-20 20:28       ` Stephen Eglen
  2010-01-21 15:02         ` Carsten Dominik
  2010-01-21 15:17         ` Carsten Dominik
  0 siblings, 2 replies; 7+ messages in thread
From: Stephen Eglen @ 2010-01-20 20:28 UTC (permalink / raw)
  To: Carsten Dominik; +Cc: emacs-orgmode, Matt Lundin, Stephen Eglen

Thanks Carsten.

> P.S. I know you have signed some copyright papers.  Do they cover all
> of Emacs?
yes, all of emacs.

Here is patch and suggested changelog.

thanks!
Stephen

p.s. 'M-x occur RET Non-nil means, RET' in org-agenda.el shows 33
instances of where  a comma has been placed after the word 'means'.  I
think this is wrong, and a misinterpretation of the advice from
elisp.info:

   * The documentation string for a variable that is a yes-or-no flag
     should start with words such as "Non-nil means," to make it clear
     that all non-`nil' values are equivalent and indicate explicitly
     what `nil' and non-`nil' mean.

as I think the comma before the closing quote is supposed to be outside
the quote (US style).  Likewise, grep shows this typo in many other
places in org lisp files.  Compare with files.el from Emacs, where you
always see 'Non-nil means 'without the comma.



2010-01-20  Stephen Eglen  <stephen@gnu.org>

	* org-agenda.el (org-get-time-of-day): Use
	org-agenda-time-leading-zero to allow leading zero (rather than
	space) for times.

*** /var/folders/46/46z6IiS7Fkihleb0T+9Yvk+++TI/-Tmp-/ediff20705uea	Wed Jan 20 20:18:24 2010
--- /Users/stephen/langs/emacs/elisp-ds/org-mode/lisp/org-agenda.el	Wed Jan 20 20:18:20 2010
***************
*** 805,810 ****
--- 805,816 ----
      (format "%-10s %2d %s %4d%s"
  	    dayname day monthname year weekstring)))
  
+ (defcustom org-agenda-time-leading-zero nil 
+   "Non-nil means use leading zero for military times in agenda.
+ For example, 9:30am would become 09:30 rather than  9:30."
+   :group 'org-agenda-daily/weekly
+   :type 'boolean)
+ 
  (defcustom org-agenda-weekend-days '(6 0)
    "Which days are weekend?
  These days get the special face `org-agenda-date-weekend' in the agenda
***************
*** 4902,4907 ****
--- 4908,4915 ----
  		    (mod h1 24) h1))
  	    (t0 (+ (* 100 h2) m))
  	    (t1 (concat (if (>= h1 24) "+" " ")
+ 			(if (and org-agenda-time-leading-zero
+ 				 (< t0 1000)) "0" "")
  			(if (< t0 100) "0" "")
  			(if (< t0 10)  "0" "")
  			(int-to-string t0))))

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

* Re: Re: formatting times as HH:MM with leading zeros
  2010-01-20 20:28       ` Stephen Eglen
@ 2010-01-21 15:02         ` Carsten Dominik
  2010-01-21 15:17         ` Carsten Dominik
  1 sibling, 0 replies; 7+ messages in thread
From: Carsten Dominik @ 2010-01-21 15:02 UTC (permalink / raw)
  To: Stephen Eglen; +Cc: Matt Lundin, emacs-orgmode

Applied, thanks.

- Carsten

On Jan 20, 2010, at 9:28 PM, Stephen Eglen wrote:

> Thanks Carsten.
>
>> P.S. I know you have signed some copyright papers.  Do they cover all
>> of Emacs?
> yes, all of emacs.
>
> Here is patch and suggested changelog.
>
> thanks!
> Stephen
>
> p.s. 'M-x occur RET Non-nil means, RET' in org-agenda.el shows 33
> instances of where  a comma has been placed after the word 'means'.  I
> think this is wrong, and a misinterpretation of the advice from
> elisp.info:
>
>   * The documentation string for a variable that is a yes-or-no flag
>     should start with words such as "Non-nil means," to make it clear
>     that all non-`nil' values are equivalent and indicate explicitly
>     what `nil' and non-`nil' mean.
>
> as I think the comma before the closing quote is supposed to be  
> outside
> the quote (US style).  Likewise, grep shows this typo in many other
> places in org lisp files.  Compare with files.el from Emacs, where you
> always see 'Non-nil means 'without the comma.
>
>
>
> 2010-01-20  Stephen Eglen  <stephen@gnu.org>
>
> 	* org-agenda.el (org-get-time-of-day): Use
> 	org-agenda-time-leading-zero to allow leading zero (rather than
> 	space) for times.
>
> *** /var/folders/46/46z6IiS7Fkihleb0T+9Yvk+++TI/-Tmp-/ediff20705uea	 
> Wed Jan 20 20:18:24 2010
> --- /Users/stephen/langs/emacs/elisp-ds/org-mode/lisp/org-agenda.el	 
> Wed Jan 20 20:18:20 2010
> ***************
> *** 805,810 ****
> --- 805,816 ----
>      (format "%-10s %2d %s %4d%s"
>  	    dayname day monthname year weekstring)))
>
> + (defcustom org-agenda-time-leading-zero nil
> +   "Non-nil means use leading zero for military times in agenda.
> + For example, 9:30am would become 09:30 rather than  9:30."
> +   :group 'org-agenda-daily/weekly
> +   :type 'boolean)
> +
>  (defcustom org-agenda-weekend-days '(6 0)
>    "Which days are weekend?
>  These days get the special face `org-agenda-date-weekend' in the  
> agenda
> ***************
> *** 4902,4907 ****
> --- 4908,4915 ----
>  		    (mod h1 24) h1))
>  	    (t0 (+ (* 100 h2) m))
>  	    (t1 (concat (if (>= h1 24) "+" " ")
> + 			(if (and org-agenda-time-leading-zero
> + 				 (< t0 1000)) "0" "")
>  			(if (< t0 100) "0" "")
>  			(if (< t0 10)  "0" "")
>  			(int-to-string t0))))
>
>

- Carsten

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

* Re: Re: formatting times as HH:MM with leading zeros
  2010-01-20 20:28       ` Stephen Eglen
  2010-01-21 15:02         ` Carsten Dominik
@ 2010-01-21 15:17         ` Carsten Dominik
  1 sibling, 0 replies; 7+ messages in thread
From: Carsten Dominik @ 2010-01-21 15:17 UTC (permalink / raw)
  To: Stephen Eglen; +Cc: Matt Lundin, emacs-orgmode


On Jan 20, 2010, at 9:28 PM, Stephen Eglen wrote:
>
> p.s. 'M-x occur RET Non-nil means, RET' in org-agenda.el shows 33
> instances of where  a comma has been placed after the word 'means'.  I
> think this is wrong, and a misinterpretation of the advice from
> elisp.info:
>
>   * The documentation string for a variable that is a yes-or-no flag
>     should start with words such as "Non-nil means," to make it clear
>     that all non-`nil' values are equivalent and indicate explicitly
>     what `nil' and non-`nil' mean.
>
> as I think the comma before the closing quote is supposed to be  
> outside
> the quote (US style).  Likewise, grep shows this typo in many other
> places in org lisp files.  Compare with files.el from Emacs, where you
> always see 'Non-nil means 'without the comma.

OK, I fixed these as well.  Can't push right now for some reason, so  
it will be in the next push when things work again.

THANKS

- Carsten

>
>
>
> 2010-01-20  Stephen Eglen  <stephen@gnu.org>
>
> 	* org-agenda.el (org-get-time-of-day): Use
> 	org-agenda-time-leading-zero to allow leading zero (rather than
> 	space) for times.
>
> *** /var/folders/46/46z6IiS7Fkihleb0T+9Yvk+++TI/-Tmp-/ediff20705uea	 
> Wed Jan 20 20:18:24 2010
> --- /Users/stephen/langs/emacs/elisp-ds/org-mode/lisp/org-agenda.el	 
> Wed Jan 20 20:18:20 2010
> ***************
> *** 805,810 ****
> --- 805,816 ----
>      (format "%-10s %2d %s %4d%s"
>  	    dayname day monthname year weekstring)))
>
> + (defcustom org-agenda-time-leading-zero nil
> +   "Non-nil means use leading zero for military times in agenda.
> + For example, 9:30am would become 09:30 rather than  9:30."
> +   :group 'org-agenda-daily/weekly
> +   :type 'boolean)
> +
>  (defcustom org-agenda-weekend-days '(6 0)
>    "Which days are weekend?
>  These days get the special face `org-agenda-date-weekend' in the  
> agenda
> ***************
> *** 4902,4907 ****
> --- 4908,4915 ----
>  		    (mod h1 24) h1))
>  	    (t0 (+ (* 100 h2) m))
>  	    (t1 (concat (if (>= h1 24) "+" " ")
> + 			(if (and org-agenda-time-leading-zero
> + 				 (< t0 1000)) "0" "")
>  			(if (< t0 100) "0" "")
>  			(if (< t0 10)  "0" "")
>  			(int-to-string t0))))
>
>

- Carsten

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

end of thread, other threads:[~2010-01-21 15:18 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-01-20  9:51 formatting times as HH:MM with leading zeros Stephen Eglen
2010-01-20 12:59 ` Matt Lundin
2010-01-20 17:29   ` Stephen Eglen
2010-01-20 19:02     ` Carsten Dominik
2010-01-20 20:28       ` Stephen Eglen
2010-01-21 15:02         ` Carsten Dominik
2010-01-21 15:17         ` 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).