help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: Syntax for <%%(diary-float )>


From: Jean Louis
Subject: Re: Syntax for <%%(diary-float )>
Date: Wed, 12 Oct 2022 22:37:19 +0300
User-agent: Mutt/2.2.7+37 (a90f69b) (2022-09-02)

* Renato Pontefice <renato.pontefice@gmail.com> [2022-10-12 21:21]:
> It’s a while that I’m searching information about this statement. I
> need it on org mode but I ‘m unable to write in in the way I need
> it.  I need that (in org mode) an Agenda TODO happen: the first
> Friday of each mont of all the year.  Can someone tell me the exact
> syntax if this statement?

(diary-float 1 1 1) this gives me void variable date, there is
problem.

Use C-h f on function to examine it:

{C-h f diary-float RET}

diary-float is a Lisp closure in ‘diary-lib.el’.

(diary-float MONTH DAYNAME N &optional DAY MARK)

Diary entry for the Nth DAYNAME after/before MONTH DAY.
DAYNAME=0 means Sunday, DAYNAME=1 means Monday, and so on.
If N>0, use the Nth DAYNAME after MONTH DAY.
If N<0, use the Nth DAYNAME before MONTH DAY.
DAY defaults to 1 if N>0, and MONTH’s last day otherwise.
MONTH can be a list of months, an integer, or t (meaning all months).
Optional MARK specifies a face or single-character string to use when
highlighting the day in the calendar.

-------------

I guess there is nothing bad using external tools to get the
information you want.

The sqlite3 database, will give this result:

sqlite> SELECT DATE('2022-11-01', 'start of month', 'weekday 5');
2022-11-04

It means now we can easily calculate which date is first day of month,
by doing the list:

(defun my-fridays ()
  (interactive)
  (insert "\n\n")
  (let ((years '(2022 2023 2024)))
    (while years
      (let ((year (pop years))
            (months '("01" "02" "03" "04" "05" "06" "07" "08" "09" "10" "11" 
"12")))
        (while months
          (let* ((month (pop months))
                 (date (format "%s-%s-01" year month))
                 (sql (format "SELECT DATE('%s', 'start of month', 'weekday 
5')" date)))
            (insert (caar (sqlite-select rcd-people-sqlite-db sql)) "\n")))))))

(my-fridays)

2022-01-07
2022-02-04
2022-03-04
2022-04-01
2022-05-06
2022-06-03
2022-07-01
2022-08-05
2022-09-02
2022-10-07
2022-11-04
2022-12-02
2023-01-06
2023-02-03
2023-03-03
2023-04-07
2023-05-05
2023-06-02
2023-07-07
2023-08-04
2023-09-01
2023-10-06
2023-11-03
2023-12-01
2024-01-05
2024-02-02
2024-03-01
2024-04-05
2024-05-03
2024-06-07
2024-07-05
2024-08-02
2024-09-06
2024-10-04
2024-11-01
2024-12-06

Now you could use this function to set up events. I do not know how do you set 
it up.

-- 
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/



reply via email to

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