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

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

Re: Anniversary in Chinese calendar date


From: Leo
Subject: Re: Anniversary in Chinese calendar date
Date: Mon, 17 Nov 2008 17:28:43 +0000
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux)

On 2008-11-17 10:16 +0000, Leo wrote:
> Hi there,
>
> In the south of China, people are still celebrating their birthdays in
> Chinese calendar date. I would like to add all my friends there in this
> way so that I can promptly send them my gifts.
>
> Any idea how to do this with Emacs calendar?
>
> Thank you.

I have come up with this function to be used in the diary file.

(defun diary-chinese-anniversary (lunar-month lunar-day &optional year mark)
  (let* ((ddate (diary-make-date lunar-month lunar-day year))
         (dd (calendar-extract-day ddate))
         (mm (calendar-extract-month ddate))
         (yy (calendar-extract-year ddate))
         (a-date (calendar-absolute-from-gregorian date))
         (c-date (calendar-chinese-from-absolute a-date))
         (mm2 (nth 2 c-date))
         (dd2 (nth 3 c-date))
         (y (calendar-extract-year date))
         (diff (if year (- y year) 100)))
    (and (> diff 0) (= mm mm2) (= dd dd2)
         (cons mark (format entry diff (diary-ordinal-suffix diff))))))

Now you can use something like:

%%(diary-chinese-anniversary 10 11 1983) Someone's %d%s Birthday

-- 
.:  Leo  :.  [ sdl.web AT gmail.com ]  .:  [ GPG Key: 9283AA3F ]  :.

        Use the better alternative -- http://www.openoffice.org/





reply via email to

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