Browse Source

New option to get times in agenda zero padded instead of blank padded

Patch by Stephen Eglen, who 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...... ----------------

This patch introduces a new user option to select this behavior.
Carsten Dominik 15 years ago
parent
commit
b034a4e1ed
2 changed files with 14 additions and 0 deletions
  1. 6 0
      lisp/ChangeLog
  2. 8 0
      lisp/org-agenda.el

+ 6 - 0
lisp/ChangeLog

@@ -1,3 +1,9 @@
+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.
+
 2010-01-20  Carsten Dominik  <carsten.dominik@gmail.com>
 
 	* org-agenda.el (org-agenda-diary-entry-in-org-file): Make sure

+ 8 - 0
lisp/org-agenda.el

@@ -805,6 +805,12 @@ This function makes sure that dates are aligned for easy reading."
     (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,6 +4908,8 @@ HH:MM."
 		    (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))))