Emacs: Adding Chinese Lunar Calendar Anniversaries
Anniversaries can be displayed in the org-agenda. To add a Gregorian anniversary, you can insert the following code into a new line in one of your org-agenda-files (note that ISO date format is enabled here):
;; Enable ISO date style: Year Month Day
(setq calendar-date-style 'iso)
%%(diary-anniversary 1949 10 1) The %dth Gregorian birthday of New China
On October 1st, it will appear at the bottom of the daily schedule in the org-agenda as follows:
The 75th Gregorian birthday of New China
Adding anniversaries based on the Lunar (Chinese) calendar requires a different function, diary-chinese-anniversary. However, the third optional argument year accepted by this function is a combination of the cycle number and the year index within the Chinese sexagenary cycle, meaning you cannot simply input the Gregorian year.
Taking the Lunar date of the 10th day of the 8th month, 1949 (which corresponds to October 1, 1949, in the Gregorian calendar) as an example, here is the setup (using ISO date style):
;; Enable ISO date style: Year Month Day
(setq calendar-date-style 'iso)
;; Enable the built-in cal-china package
(require 'cal-china)
;; The diary-chinese-anniversary function in cal-china only supports
;; the American date format, so we need to use 'let' to locally define the variable.
(defun my/diary-chinese-anniversary (year month day)
(let ((calendar-date-style 'american))
(diary-chinese-anniversary month day year nil)))
;; Calculate the Chinese lunar year structure for a given Gregorian date
(defun my/chinese-year (year month day)
(+ (* 100 (car (calendar-chinese-from-absolute (calendar-absolute-from-gregorian (diary-make-date year month day)))))
(cadr (calendar-chinese-from-absolute (calendar-absolute-from-gregorian (diary-make-date year month day))))))
With this setup, you can use the following code to display the lunar birthday reminder for the 10th day of the 8th lunar month, 1949 (Gregorian: October 1, 1949).
%%(my/diary-chinese-anniversary (my/chinese-year 1949 10 1) 8 10) The %dth Lunar birthday of New China