all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Anniversary in Chinese calendar date
@ 2008-11-17 10:16 Leo
  2008-11-17 17:28 ` Leo
  0 siblings, 1 reply; 2+ messages in thread
From: Leo @ 2008-11-17 10:16 UTC (permalink / raw
  To: help-gnu-emacs

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.
-- 
.:  Leo  :.  [ sdl.web AT gmail.com ]  .:  [ GPG Key: 9283AA3F ]  :.

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





^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Anniversary in Chinese calendar date
  2008-11-17 10:16 Anniversary in Chinese calendar date Leo
@ 2008-11-17 17:28 ` Leo
  0 siblings, 0 replies; 2+ messages in thread
From: Leo @ 2008-11-17 17:28 UTC (permalink / raw
  To: help-gnu-emacs

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/





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-11-17 17:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-17 10:16 Anniversary in Chinese calendar date Leo
2008-11-17 17:28 ` Leo

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.