#+TITLE: Fun with Org Mode Agenda Views
#+DATE: 2022-12-28
I use [[https://orgmode.org/][Org Mode]] extensively, including [[https://orgmode.org/manual/Agenda-Views.html][Agenda Views]].
I have an =anniversaries.org= file for, well, anniversaries. I have
added it to the ~org-agenda-files~ list so that entries in there show
up in agenda views.
It contains some non-standard entries that some people might get a
giggle out of.
* Discordian Holidays
#+begin_example
%%(org-anniversary -1166 01 05) Today is Setting Orange, the 5th day of Chaos in the YOLD %d. Celebrate Mungday.
%%(org-anniversary -1166 02 19) Today is Setting Orange, the 50th day of Chaos in the YOLD %d. Celebrate Chaoflux.
%%(org-anniversary -1166 03 19) Today is Pungenday, the 5th day of Discord in the YOLD %d. Celebrate Mojoday.
%%(org-anniversary -1166 05 03) Today is Pungenday, the 50th day of Discord in the YOLD %d. Celebrate Discoflux.
%%(org-anniversary -1166 05 31) Today is Sweetmorn, the 5th day of Confusion in the YOLD %d. Celebrate Syaday.
%%(org-anniversary -1166 07 15) Today is Sweetmorn, the 50th day of Confusion in the YOLD %d. Celebrate Confuflux.
%%(org-anniversary -1166 08 12) Today is Prickle-Prickle, the 5th day of Bureaucracy in the YOLD %d. Celebrate Zaraday.
%%(org-anniversary -1166 09 26) Today is Prickle-Prickle, the 50th day of Bureaucracy in the YOLD %d. Celebrate Bureflux.
%%(org-anniversary -1166 10 24) Today is Boomtime, the 5th day of The Aftermath in the YOLD %d. Celebrate Maladay.
%%(org-anniversary -1166 12 08) Today is Boomtime, the 50th day of The Aftermath in the YOLD %d. Celebrate Afflux.
#+end_example
* Discworld
#+begin_example
%%(org-anniversary 1957 5 24) The Glorious People's Republic of Treacle Mine Road: "Truth, Justice, Freedom, Reasonably-Priced Love and a Hard-Boiled Egg!"
#+end_example
* Shitposting
#+begin_example
%%(org-anniversary 0 12 23) Christmas Adam. Comes before Christmas Eve and is generally unsatisfying.
%%(= 0 (calendar-days-from-easter)) Celebrate the rising of an undead horror from his tomb...
#+end_example
"Christmas Adam" came from a [[https://theguilteaparty.tumblr.com/post/69069034510][tumblr thread]] years ago.

"Celebrating the rising of an undead horror" came from a conversation
between [[https://thecooltable.wtf/@ncweaver/109574943089507499][Charlie Stross and Nicholas Weaver on the Fediverse]].

For the later we need a helper function to calculate the [[https://en.wikipedia.org/wiki/Date_of_Easter][Date of
Easter]].
* Calculate Easter
This is from the Org Mode FAQ: [[https://orgmode.org/worg/org-faq.html#org3d76864][17.8. How do I schedule events relative
to Easter Sunday?]] Which points at [[https://github.com/soren/elisp/blob/master/da-kalender.el][da-kalender.el]]
#+begin_src emacs-lisp
  ;; from https://github.com/soren/elisp/blob/master/da-kalender.el
  ;; Copyright (c) 2018 Søren Lund <soren@lund.org>
  ;; This program is free software; you can redistribute it and/or modify
  ;; it under the terms of the GNU General Public License as published by
  ;; the Free Software Foundation; either version 3 of the License, or
  ;; (at your option) any later version.
  (defun calendar-easter (year)
    "Calculate the date for Easter Sunday in YEAR."
    (let* ((century (1+ (/ year 100)))
           (shifted-epact (% (+ 14 (* 11 (% year 19))
                                (- (/ (* 3 century) 4))
                                (/ (+ 5 (* 8 century)) 25)
                                (* 30 century))
                             30))
           (adjusted-epact (if (or (= shifted-epact 0)
                                   (and (= shifted-epact 1)
                                        (< 10 (% year 19))))
                               (1+ shifted-epact)
                             shifted-epact))
           (paschal-moon (- (calendar-absolute-from-gregorian
                             (list 4 19 year))
                            adjusted-epact)))
      (calendar-dayname-on-or-before 0 (+ paschal-moon 7))))
  (defun calendar-easter-gregorian (year)
    (calendar-gregorian-from-absolute (da-easter year)))
  (defun calendar-days-from-easter ()
    "When used in a diary sexp, this function will calculate how many days
  are between the current date (DATE) and Easter Sunday."
    (- (calendar-absolute-from-gregorian date)
       (calendar-easter (calendar-extract-year date))))
#+end_src
We can then schedule things relative to Easter:
+ Good Friday :: ~<%%(= -2 (calendar-days-from-easter))>~
+ Easter Sunday :: ~<%%(= 0 (calendar-days-from-easter))>~
+ Easter Monday :: ~<%%(= 1 (calendar-days-from-easter))>~
