emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: David Rogers <davidandrewrogers@gmail.com>
To: Ihor Radchenko <yantar92@posteo.net>
Cc: Org-mode list <emacs-orgmode@gnu.org>
Subject: Re: Diary sexp and comparing dates, agenda
Date: Fri, 12 Jan 2024 21:41:42 -0800	[thread overview]
Message-ID: <rzhmst9g57t.fsf@gmail.com> (raw)
In-Reply-To: <87jzoenomm.fsf@localhost> (Ihor Radchenko's message of "Fri, 12 Jan 2024 23:00:33 +0000")

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	other threads:[~2024-01-13  5:43 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-12  5:58 Diary sexp and comparing dates, agenda David Rogers
2024-01-12 17:01 ` Tory S. Anderson
2024-01-12 18:11 ` Ken Mankoff
2024-01-12 23:00 ` Ihor Radchenko
2024-01-13  5:41   ` David Rogers [this message]
2024-01-13 20:05     ` Ihor Radchenko
2024-01-13 23:44       ` David Rogers

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=rzhmst9g57t.fsf@gmail.com \
    --to=davidandrewrogers@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=yantar92@posteo.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).