diff options
author | Marcel van der Boom <marcel@hsdev.com> | 2022-12-07 13:01:29 +0100 |
---|---|---|
committer | Bastien Guerry <bzg@gnu.org> | 2022-12-07 14:26:06 +0100 |
commit | 0927d5f319d6168b0df3a118f2269535a15557ef (patch) | |
tree | aed45ceb42ca6e45fda7724dd371f20dbb0b8350 | |
parent | 442e80dc9597617b1a29271d998792c371f3d42a (diff) |
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.
-rw-r--r-- | lisp/org-expiry.el | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/lisp/org-expiry.el b/lisp/org-expiry.el index 98ad58a..b359610 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 |