branch: externals/iso-date
commit 0d44051c71ab3409bbdf7dac5a4625cff589fe14
Author: Lucas Quintana <lm...@protonmail.com>
Commit: Lucas Quintana <lm...@protonmail.com>

    Add iso-date-echo-difference, iso-date-pretty-print
---
 README.md   |  5 +++++
 iso-date.el | 21 +++++++++++++++++++++
 2 files changed, 26 insertions(+)

diff --git a/README.md b/README.md
index 207f1cbef7..71a49d03f5 100644
--- a/README.md
+++ b/README.md
@@ -20,6 +20,11 @@ There are also commands to insert or manipulate ISO dates:
 - iso-date-at-point-day-down
 - iso-date-at-point-do-shift
 
+Or display information about them:
+
+- iso-date-echo-difference
+- iso-date-pretty-print
+
 ## For developers
 
 This library provides the `iso-date` function. Without arguments, it returns 
an ISO date string for current day:
diff --git a/iso-date.el b/iso-date.el
index c52bfcef2e..a9a752515f 100644
--- a/iso-date.el
+++ b/iso-date.el
@@ -222,6 +222,8 @@ This is an alternative to the plist-based modification 
offered by
     (calc)
     (calc-push-list `((date ,abs)))))
 
+;;;; Insertion and manipulation
+
 (declare-function org-read-date "org")
 
 (defun iso-date-insert (&optional arg)
@@ -264,6 +266,25 @@ See `iso-date-shift' for the values SHIFT can take."
       (delete-region (car bounds) (cdr bounds))
       (insert (iso-date-shift shift date)))))
 
+;;;; Displaying useful information
+
+(defun iso-date-echo-difference (date)
+  "Echo day difference between current date and DATE."
+  (interactive (list (iso-date--read)))
+  (let ((day-difference (- (date-to-day date) (time-to-days nil))))
+    (cond ((> day-difference 0)
+           (message "This date will arrive in %d days" day-difference))
+          ((< day-difference 0)
+           (message "This date was %d days ago" (- day-difference)))
+          (t
+           (message "This is today's date")))))
+
+(defun iso-date-pretty-print (date)
+  "Echo a pretty representation for DATE.
+Format is defined by the variable `calendar-date-display-form'."
+  (interactive (list (iso-date--read)))
+  (message (calendar-date-string (iso-date-to-calendar date))))
+
 ;;;; Misc.
 
 (defun iso-date-between-dates-p (start end date)

Reply via email to