emacs-orgmode
[Top][All Lists]
Advanced

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

Re: Diary sexp and comparing dates, agenda


From: David Rogers
Subject: Re: Diary sexp and comparing dates, agenda
Date: Fri, 12 Jan 2024 21:41:42 -0800
User-agent: Gnus/5.13 (Gnus v5.13)

Ihor Radchenko <yantar92@posteo.net> writes:

You don't need diary-float - it returns true/false whether current DATE
fits the arguments.

Instead, you can make use of `calendar-nth-named-absday'.
For example,

<%%(and (= 245 (mf-days-from-easter))
        (< (calendar-absolute-from-gregorian date)
           (calendar-nth-named-absday -4 0 12 24)))>

Diary sexps are nothing but ordinary Elisp, with an extra twist that during evaluation `date' variable is bound to current calendar date.
When they return nil, DATE does not match.


Thank you!

It seems that `calendar-nth-named-absday' wants the year after the month, and then an (optional) day of the month to count from. Since I hoped to keep re-using this material every year without re-entering the calculations, I've tried the following:

In my init file, I've added these two short definitions:

   (defun mf-beginning-of-advent (displayed-year)
     (calendar-nth-named-absday -4 0 12 displayed-year 24))

   (defun mf-days-from-advent ()
(- (calendar-absolute-from-gregorian date) (mf-beginning-of-advent (calendar-extract-year date))))

And my Org file has this:

* Example 1
<%%(and (= 245 (mf-days-from-easter)) (<= (mf-days-from-advent) -1))>


This setup seems to work so far. Does it look reasonable to you?

--
David



reply via email to

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