0
0
Fork 1
mirror of https://git.savannah.gnu.org/git/emacs/org-mode.git synced 2024-09-29 18:00:49 +00:00

agenda: Fix org-duration-to-minutes error (take 2)

* lisp/org.el (org-stamp-time-of-day-regexp): Limit match group 2 to
first time.
* lisp/org-agenda.el (org-agenda-format-item): Compute duration before
formatting time with `org-get-time-of-day'.
This commit is contained in:
Nicolas Goaziou 2021-05-11 09:39:08 +02:00 committed by Bastien
parent 88fbe21a88
commit dcb6013fb6
2 changed files with 5 additions and 8 deletions

View file

@ -6739,10 +6739,6 @@ Any match of REMOVE-RE will be removed from TXT."
(= (match-beginning 0) 0)
t))
(setq txt (replace-match "" nil nil txt))))
;; Normalize the time(s) to 24 hour
(when s1 (setq s1 (org-get-time-of-day s1 'string t)))
(when s2 (setq s2 (org-get-time-of-day s2 'string t)))
;; Try to set s2 if s1 and
;; `org-agenda-default-appointment-duration' are set
(when (and s1 (not s2) org-agenda-default-appointment-duration)
@ -6751,12 +6747,13 @@ Any match of REMOVE-RE will be removed from TXT."
(+ (org-duration-to-minutes s1 t)
org-agenda-default-appointment-duration)
nil t)))
;; Compute the duration
(when s2
(setq duration (- (org-duration-to-minutes s2)
(org-duration-to-minutes s1)))))
(org-duration-to-minutes s1))))
;; Normalize the time(s) to 24 hour
(when s1 (setq s1 (org-get-time-of-day s1 'string t)))
(when s2 (setq s2 (org-get-time-of-day s2 'string t))))
(when (string-match org-tag-group-re txt)
;; Tags are in the string
(if (or (eq org-agenda-remove-tags t)

View file

@ -4117,7 +4117,7 @@ groups carry important information:
(defconst org-stamp-time-of-day-regexp
(concat
"<\\([0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\} +\\sw+ +\\)"
"\\([012][0-9]:[0-5][0-9]\\(-\\([012][0-9]:[0-5][0-9]\\)\\)?[^\n\r>]*?\\)>"
"\\([012][0-9]:[0-5][0-9]\\)\\(-\\([012][0-9]:[0-5][0-9]\\)\\)?[^\n\r>]*?>"
"\\(--?"
"<\\1\\([012][0-9]:[0-5][0-9]\\)>\\)?")
"Regular expression to match a timestamp time or time range.