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

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

[nongnu] elpa/org-contrib 0927d5f319: Fix formatting of inserted timesta


From: ELPA Syncer
Subject: [nongnu] elpa/org-contrib 0927d5f319: Fix formatting of inserted timestamps
Date: Wed, 7 Dec 2022 08:59:53 -0500 (EST)

branch: elpa/org-contrib
commit 0927d5f319d6168b0df3a118f2269535a15557ef
Author: Marcel van der Boom <marcel@hsdev.com>
Commit: Bastien Guerry <bzg@gnu.org>

    Fix formatting of inserted timestamps
    
    Make handling the timestamps internally consistent, i.e. without the 
delimiters and use a dedicated
    helper to format them based on the value of the 
`org-expiry-inactive-timestamps variable.
---
 lisp/org-expiry.el | 29 ++++++++++++++---------------
 1 file changed, 14 insertions(+), 15 deletions(-)

diff --git a/lisp/org-expiry.el b/lisp/org-expiry.el
index 98ad58a3ab..b3596101fd 100644
--- a/lisp/org-expiry.el
+++ b/lisp/org-expiry.el
@@ -282,6 +282,9 @@ The expiry process will run the function defined by
                   processed expired))))))
 
 ;;; Insert created/expiry property:
+(defun org-expiry-format-timestamp (timestr inactive)
+  "Properly format TIMESTR into an org (in)active timestamp"
+  (format (if inactive "[%s]" "<%s>") timestr))
 
 (defun org-expiry-insert-created (&optional arg)
   "Insert or update a property with the creation date.
@@ -298,14 +301,12 @@ update the date."
                     (current-time)))
       (setq d-hour (format-time-string "%H:%M" d-time))
       (setq timestr
-           ;; two C-u prefixes will call org-read-date
-           (if (equal arg '(16))
-               (concat "<" (org-read-date
-                            nil nil nil nil d-time d-hour) ">")
-             (format-time-string (cdr org-time-stamp-formats))))
-      ;; maybe transform to inactive timestamp
-      (if org-expiry-inactive-timestamps
-         (setq timestr (concat "[" (substring timestr 1 -1) "]")))
+            (org-expiry-format-timestamp
+             ;; two C-u prefixes will call org-read-date
+            (if (equal arg '(16))
+                (org-read-date nil nil nil nil d-time d-hour)
+              (format-time-string (cdr org-time-stamp-formats)))
+             org-expiry-inactive-timestamps))
       (save-excursion
        (org-entry-put
         (point) org-expiry-created-property-name timestr)))))
@@ -320,13 +321,11 @@ and insert today's date."
     (setq d-time (if d (org-time-string-to-time d)
                   (current-time)))
     (setq d-hour (format-time-string "%H:%M" d-time))
-    (setq timestr (if today
-                     (format-time-string (cdr org-time-stamp-formats))
-                   (concat "<" (org-read-date
-                                nil nil nil nil d-time d-hour) ">")))
-    ;; maybe transform to inactive timestamp
-    (if org-expiry-inactive-timestamps
-       (setq timestr (concat "[" (substring timestr 1 -1) "]")))
+    (setq timestr (org-expiry-format-timestamp
+                   (if today
+                      (format-time-string (cdr org-time-stamp-formats))
+                    (org-read-date nil nil nil nil d-time d-hour))
+                   org-expiry-inactive-timestamps))
 
     (save-excursion
       (org-entry-put



reply via email to

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