emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/org e8562a3: date/time prompt: Provide support for HHhM


From: ELPA Syncer
Subject: [elpa] externals/org e8562a3: date/time prompt: Provide support for HHhMM time input
Date: Sat, 1 May 2021 11:57:10 -0400 (EDT)

branch: externals/org
commit e8562a332747a9bae1f0ea984f1dbac61a5f8a4e
Author: Gustavo Barros <gusbrs.2016@gmail.com>
Commit: Bastien Guerry <bzg@gnu.org>

    date/time prompt: Provide support for HHhMM time input
    
    * lisp/org.el (org-read-date-analyze): Add support for HHhMM time
    input, in similar way as for am/pm times.
    * doc/org-manual.org (The date/time prompt): Add example to illustrate
    the feature.
    
    TINYCHANGE
---
 doc/org-manual.org |  1 +
 lisp/org.el        | 13 +++++++++++++
 2 files changed, 14 insertions(+)

diff --git a/doc/org-manual.org b/doc/org-manual.org
index 1025288..d82370d 100644
--- a/doc/org-manual.org
+++ b/doc/org-manual.org
@@ -6060,6 +6060,7 @@ dash(es) as the separator in the former case and use =+= 
as the
 separator in the latter case, e.g.:
 
 | =11am-1:15pm=  | \rArr{} 11:00-13:15   |
+| =11h-13h15=    | \rArr{} same as above |
 | =11am--1:15pm= | \rArr{} same as above |
 | =11am+2:15=    | \rArr{} same as above |
 
diff --git a/lisp/org.el b/lisp/org.el
index d6f3875..461536a 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -14104,6 +14104,19 @@ user."
               (setq ans (replace-match (format "%02d:%02d" hour minute)
                                        t t ans))))
 
+    ;; Help matching HHhMM times, similarly as for am/pm times.
+    (cl-loop for i from 1 to 2 do      ; twice, for end time as well
+            (when (and (not (string-match 
"\\(\\`\\|[^+]\\)[012]?[0-9]:[0-9][0-9]\\([ \t\n]\\|$\\)" ans))
+                       (string-match 
"\\(?:\\(?1:[012]?[0-9]\\)?h\\(?2:[0-5][0-9]\\)\\)\\|\\(?:\\(?1:[012]?[0-9]\\)h\\(?2:[0-5][0-9]\\)?\\)\\>"
 ans))
+              (setq hour (if (match-end 1)
+                               (string-to-number (match-string 1 ans))
+                             0)
+                    minute (if (match-end 2)
+                               (string-to-number (match-string 2 ans))
+                             0))
+              (setq ans (replace-match (format "%02d:%02d" hour minute)
+                                       t t ans))))
+
     ;; Check if a time range is given as a duration
     (when (string-match 
"\\([012]?[0-9]\\):\\([0-6][0-9]\\)\\+\\([012]?[0-9]\\)\\(:\\([0-5][0-9]\\)\\)?"
 ans)
       (setq hour (string-to-number (match-string 1 ans))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]