branch: externals/iso-date commit b922a4c51b96378cf20a4f9273a9368b3054d0a1 Author: Lucas Quintana <lm...@protonmail.com> Commit: Lucas Quintana <lm...@protonmail.com>
Add iso-date-list-dates-between --- README.md | 1 + iso-date.el | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/README.md b/README.md index 09ccc4fa87..207f1cbef7 100644 --- a/README.md +++ b/README.md @@ -68,6 +68,7 @@ For extracting values: Others: - iso-date-between-dates-p +- iso-date-list-dates-between Last but not least, this library can add `date` as a thing recognized by the `thingatpt` library. Just add the following to your init file: diff --git a/iso-date.el b/iso-date.el index a8a689b3ce..fb2f41db84 100644 --- a/iso-date.el +++ b/iso-date.el @@ -273,6 +273,22 @@ See `iso-date-shift' for the values SHIFT can take." (equal start date) (equal end date))) +(defun iso-date-list-dates-between (start end) + "Return a list with all dates between START and END. +START and END should be ISO 8601 date strings. + +Returned dates are also in that format." + (let* ((time1 (iso-date-to-internal start)) + (time2 (iso-date-to-internal end)) + (pointer time1) + (one-day (make-decoded-time :day 1)) + dates) + (while (not (equal pointer time2)) + (push (format-time-string "%F" pointer) dates) + (setq pointer (encode-time (decoded-time-add (decode-time pointer) one-day)))) + (push (format-time-string "%F" time2) dates) + (reverse dates))) + ;;;; thingatpt.el integration (defun iso-date-configure-thingatpt ()