Hello,

Trevor Murphy <trevor.m.mur...@gmail.com> writes:

> * lisp/org.el (org-get-compact-tod): Pad with "0" if # of minutes is
>   less than 10.

Thanks for your patch. Would you mind providing a test-case for it? I'm
not sure about the use of `org-get-compact-tod'.

> ---
>  lisp/org.el | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/lisp/org.el b/lisp/org.el
> index 26e653f..89e023c 100644
> --- a/lisp/org.el
> +++ b/lisp/org.el
> @@ -16088,9 +16088,12 @@ with the current time without prompting the user."
>        (if (not t2)
>         t1
>       (setq dh (- h2 h1) dm (- m2 m1))
> -     (if (< dm 0) (setq dm (+ dm 60) dh (1- dh)))
> +     (when (< dm 0) (setq dm (+ dm 60) dh (1- dh)))

Although I agree with this change, this is not strictly necessary here.

>       (concat t1 "+" (number-to-string dh)
> -             (if (/= 0 dm) (concat ":" (number-to-string dm))))))))
> +             (when (/= 0 dm) (concat ":"
> +                                        (if (< dm 10)
> +                                            (concat "0" (number-to-string 
> dm))
> +                                          (number-to-string dm)))))))))

It would be better to use a 0-padded format string, e.g.,

  (and (/= 0 dm) (format ":%02d" dm))


Regards,

-- 
Nicolas Goaziou

Reply via email to