Function: diary-anniversary
diary-anniversary is a byte-compiled function defined in
diary-lib.el.gz.
Signature
(diary-anniversary MONTH DAY &optional YEAR MARK)
Documentation
Anniversary diary entry.
Entry applies if date is the anniversary of MONTH, DAY, YEAR.
The order of the input parameters changes according to
calendar-date-style (e.g. to DAY MONTH YEAR in the European style).
The diary entry can contain %d or %d%s; the %d will be replaced
by the number of years since the MONTH, DAY, YEAR, and the %s will
be replaced by the ordinal ending of that number (that is, st,
nd, rd or th, as appropriate). The anniversary of February 29
is considered to be March 1 in non-leap years.
An optional parameter MARK specifies a face or single-character string to use when highlighting the day in the calendar.
Source Code
;; Defined in /usr/src/emacs/lisp/calendar/diary-lib.el.gz
;; To be called from diary-sexp-entry, where DATE, ENTRY are bound.
(defun diary-anniversary (month day &optional year mark)
"Anniversary diary entry.
Entry applies if date is the anniversary of MONTH, DAY, YEAR.
The order of the input parameters changes according to
`calendar-date-style' (e.g. to DAY MONTH YEAR in the European style).
The diary entry can contain `%d' or `%d%s'; the %d will be replaced
by the number of years since the MONTH, DAY, YEAR, and the %s will
be replaced by the ordinal ending of that number (that is, `st',
`nd', `rd' or `th', as appropriate). The anniversary of February 29
is considered to be March 1 in non-leap years.
An optional parameter MARK specifies a face or single-character
string to use when highlighting the day in the calendar."
(with-no-warnings (defvar date) (defvar entry))
(let* ((ddate (diary-make-date month day year))
(dd (calendar-extract-day ddate))
(mm (calendar-extract-month ddate))
(yy (calendar-extract-year ddate))
(y (calendar-extract-year date))
(diff (if yy (- y yy) 100)))
(and (= mm 2) (= dd 29) (not (calendar-leap-year-p y))
(setq mm 3
dd 1))
(and (> diff 0) (calendar-date-equal (list mm dd y) date)
(cons mark (format entry diff (diary-ordinal-suffix diff))))))