💾 Archived View for irek.xyz › gemlog › 2021-06-19.gmi captured on 2022-01-08 at 14:14:35. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2021-11-30)

-=-=-=-=-=-=-

I wanted to use Emacs Calendar and Diary to mark last non holiday day in each month as a reminder to send invoice. Regular date format can't be that specific. Diary has special functions that helps with marking abstract dates but as far as my research goes It can't mark last non holiday day in month.

No hope is lost when you can write your own code. First I read very end of "the Calendar and the Diary" info page where I found secret knowledge.

(info "(emacs) Sexp Diary Entries")

Then I wrote elisp expression inside diary file:

%%(seq-let (month day year) date
    (let ((last-day (date-days-in-month year month)))
      (while (seq-contains calendar-weekend-days
                           (calendar-day-of-week (list month last-day year)))
        (setq last-day (1- last-day)))
      (if (= day last-day) '(error . "Invoice"))))

Code takes last day of given month and check if it's not a weekend day. If it is then go back by one day and check again. Repeat until you encounter regular day. Then check if given "date" match that day. If so then mark date using "error" face with "Invoice" description.

Lesson for today?

Read documentations and live to code another day!

EOF