|
From: | Wanrong Lin |
Subject: | Re: [O] Bug: Entries with diary-sexps in "scheduled" not exported properly to calendar file (.ics file) |
Date: | Mon, 1 Apr 2019 14:14:33 -0400 |
User-agent: | Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 |
;; example: (dates-from-diary-sexp "2019-04-01" "2019-09-01" "(diary-float t 1 2)")
;; => ((8 12 2019) (7 8 2019) (6 10 2019) (5 13 2019) (4 8 2019)) (defun dates-from-diary-sexp (start end diary-sexp)"Given a start and ending date, returns all valid dates between them that satisfy diary-sexp"
(let ((day-absolute (org-time-string-to-absolute start)) (end-absolute (org-time-string-to-absolute end)) (sexp (car (read-from-string diary-sexp))) (dates)) (while (< day-absolute end-absolute) (let ((date (calendar-gregorian-from-absolute day-absolute)) (entry nil)) (when (eval sexp) (setf dates (cons date dates))) (incf day-absolute))) dates)) On 3/26/2019 5:01 PM, Thomas Plass wrote:
Wanrong Lin wrote at 15:20 on March 26, 2019: : : As a work around, do you know if there is a way : to generate a series of dates / org entries from a diary-sexps? Thanks. Evaluating those sexp is done in diary-lib. But it's no use simply supplying arguments to functions there as they require external setup, in particular variables such the current DATE (mon day year), itself coming from calendar.el. However, it's exactly such dates that you are looking for in the first place. I guess, in your example (diary-float t 1 2) you might have to loop through all the days of all months (calendar knows about those) to see whether your sexp evaluates to something useful. But I haven't looked at that in detail. Thomas
[Prev in Thread] | Current Thread | [Next in Thread] |