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

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

Chinese date Conversion --- almost but HELP!


From: swk
Subject: Chinese date Conversion --- almost but HELP!
Date: Tue, 05 Nov 2002 19:54:33 +0900
User-agent: Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.0.1) Gecko/20020823 Netscape/7.0

Using the below emacs code (provided graciously by Jesper Harder) and taking the left 8 digit (iso date) as input
the code produced the chinese date string output.

Notice that for dates 18980422 and on the second month (leap month) does not have an
associated branch and stem this must be a problem with the calendar code.

I would like to figure out how to append the (iso date) to the output chinese date string and I would like to have the program properly output the branch and stem names for the second
(leap) months.

Also of note: I edited the code and was able to convert dates to persian and islamic using this routine. Jesper is a genius!

I just don't know enough about EMACS to make the changes in the code. I can see that the input date is picked up by EMACS on line 13 (but I don't know how to reference it down in line 20 where the write to the other buffer is taking place. As to the problem with the calendar code and the lack of branch stem names for the second (leap) month I haven't a clue, but I note that the code calls leap months by mm.5 (decimal 5) so integer math maby be involved the other months and days and years are refered to as intiger in the Book
Calendrical Calculations but the leap month is associated with a boolian.

******************* cut here **************

;;Evaluate the following, load the file with the ISO dates in a buffer and
;;do `M-x itc', which will put the Chinese dates in another
;;buffer.


10    (defun itc ()
11      (interactive)
12      (goto-char (point-min))
13 (while (re-search-forward "^\\([[:digit:]]\\{4\\}\\)\\([[:digit:]]\\{2\\}\\)\\([[:digit:]]\\{2\\}\\)" nil t)
14        (let ((str (format "%s\n" (calendar-chinese-date-string
15                                  (mapcar 'string-to-int
16                                           (list (match-string 2)
17                                                  (match-string 3)
18                                                  (match-string 1)))))))
19        (with-current-buffer (get-buffer-create "*chinese output*")
20          (insert str))))
21      (switch-to-buffer "*chinese output*"))

******************* cut here **************

yyyymmdd


18960826 Cycle 76, year 33 (Bing-Shen), month 7 (Bing-Shen), day 18 (Xin-Hai)
18970304 Cycle 76, year 34 (Ding-You), month 2 (Gui-Mao), day 2 (Xin-You)
18970808 Cycle 76, year 34 (Ding-You), month 7 (Wu-Shen), day 11 (Wu-Xu)
18971004 Cycle 76, year 34 (Ding-You), month 9 (Geng-Xu), day 9 (Yi-Wei)
18971031 Cycle 76, year 34 (Ding-You), month 10 (Xin-Hai), day 6 (Ren-Xu)
18980101 Cycle 76, year 34 (Ding-You), month 12 (Gui-Chou), day 9 (Jia-Zi)
18980112 Cycle 76, year 34 (Ding-You), month 12 (Gui-Chou), day 20 (Yi-Hai)
18980117 Cycle 76, year 34 (Ding-You), month 12 (Gui-Chou), day 25 (Geng-Chen) 18980121 Cycle 76, year 34 (Ding-You), month 12 (Gui-Chou), day 29 (Jia-Shen)
18980124 Cycle 76, year 35 (Wu-Xu), month 1 (Jia-Yin), day 3 (Ding-Hai)
18980125 Cycle 76, year 35 (Wu-Xu), month 1 (Jia-Yin), day 4 (Wu-Zi)
18980127 Cycle 76, year 35 (Wu-Xu), month 1 (Jia-Yin), day 6 (Geng-Yin)
18980209 Cycle 76, year 35 (Wu-Xu), month 1 (Jia-Yin), day 19 (Gui-Mao)
18980215 Cycle 76, year 35 (Wu-Xu), month 1 (Jia-Yin), day 25 (Ji-You)
18980216 Cycle 76, year 35 (Wu-Xu), month 1 (Jia-Yin), day 26 (Geng-Xu)
18980217 Cycle 76, year 35 (Wu-Xu), month 1 (Jia-Yin), day 27 (Xin-Hai)
18980218 Cycle 76, year 35 (Wu-Xu), month 1 (Jia-Yin), day 28 (Ren-Zi)
18980221 Cycle 76, year 35 (Wu-Xu), month 2 (Yi-Mao), day 1 (Yi-Mao)
18980225 Cycle 76, year 35 (Wu-Xu), month 2 (Yi-Mao), day 5 (Ji-Wei)
18980306 Cycle 76, year 35 (Wu-Xu), month 2 (Yi-Mao), day 14 (Wu-Chen)
18980308 Cycle 76, year 35 (Wu-Xu), month 2 (Yi-Mao), day 16 (Geng-Wu)
18980312 Cycle 76, year 35 (Wu-Xu), month 2 (Yi-Mao), day 20 (Jia-Xu)
18980314 Cycle 76, year 35 (Wu-Xu), month 2 (Yi-Mao), day 22 (Bing-Zi)
18980321 Cycle 76, year 35 (Wu-Xu), month 2 (Yi-Mao), day 29 (Gui-Wei)
18980325 Cycle 76, year 35 (Wu-Xu), first month 3 (Bing-Chen), day 4 (Ding-Hai)
18980326 Cycle 76, year 35 (Wu-Xu), first month 3 (Bing-Chen), day 5 (Wu-Zi)
18980328 Cycle 76, year 35 (Wu-Xu), first month 3 (Bing-Chen), day 7 (Geng-Yin) 18980330 Cycle 76, year 35 (Wu-Xu), first month 3 (Bing-Chen), day 9 (Ren-Chen) 18980331 Cycle 76, year 35 (Wu-Xu), first month 3 (Bing-Chen), day 10 (Gui-Si) 18980401 Cycle 76, year 35 (Wu-Xu), first month 3 (Bing-Chen), day 11 (Jia-Wu) 18980406 Cycle 76, year 35 (Wu-Xu), first month 3 (Bing-Chen), day 16 (Ji-Hai) 18980407 Cycle 76, year 35 (Wu-Xu), first month 3 (Bing-Chen), day 17 (Geng-Zi) 18980409 Cycle 76, year 35 (Wu-Xu), first month 3 (Bing-Chen), day 19 (Ren-Yin) 18980411 Cycle 76, year 35 (Wu-Xu), first month 3 (Bing-Chen), day 21 (Jia-Chen) 18980416 Cycle 76, year 35 (Wu-Xu), first month 3 (Bing-Chen), day 26 (Ji-You) 18980419 Cycle 76, year 35 (Wu-Xu), first month 3 (Bing-Chen), day 29 (Ren-Zi)
18980422 Cycle 76, year 35 (Wu-Xu), second month 3, day 2 (Yi-Mao)
18980423 Cycle 76, year 35 (Wu-Xu), second month 3, day 3 (Bing-Chen)
18980425 Cycle 76, year 35 (Wu-Xu), second month 3, day 5 (Wu-Wu)
18980427 Cycle 76, year 35 (Wu-Xu), second month 3, day 7 (Geng-Shen)
18980430 Cycle 76, year 35 (Wu-Xu), second month 3, day 10 (Gui-Hai)
18980501 Cycle 76, year 35 (Wu-Xu), second month 3, day 11 (Jia-Zi)
18980511 Cycle 76, year 35 (Wu-Xu), second month 3, day 21 (Jia-Xu)
18980512 Cycle 76, year 35 (Wu-Xu), second month 3, day 22 (Yi-Hai)
18980513 Cycle 76, year 35 (Wu-Xu), second month 3, day 23 (Bing-Zi)
18980515 Cycle 76, year 35 (Wu-Xu), second month 3, day 25 (Wu-Yin)
18980517 Cycle 76, year 35 (Wu-Xu), second month 3, day 27 (Geng-Chen)
18980522 Cycle 76, year 35 (Wu-Xu), month 4 (Ding-Si), day 3 (Yi-You)
18980525 Cycle 76, year 35 (Wu-Xu), month 4 (Ding-Si), day 6 (Wu-Zi)
18980529 Cycle 76, year 35 (Wu-Xu), month 4 (Ding-Si), day 10 (Ren-Chen)
18980531 Cycle 76, year 35 (Wu-Xu), month 4 (Ding-Si), day 12 (Jia-Wu)
18980603 Cycle 76, year 35 (Wu-Xu), month 4 (Ding-Si), day 15 (Ding-You)
18980610 Cycle 76, year 35 (Wu-Xu), month 4 (Ding-Si), day 22 (Jia-Chen)
18980612 Cycle 76, year 35 (Wu-Xu), month 4 (Ding-Si), day 24 (Bing-Wu)
18980615 Cycle 76, year 35 (Wu-Xu), month 4 (Ding-Si), day 27 (Ji-You)
18980621 Cycle 76, year 35 (Wu-Xu), month 5 (Wu-Wu), day 3 (Yi-Mao)
18980622 Cycle 76, year 35 (Wu-Xu), month 5 (Wu-Wu), day 4 (Bing-Chen)
18980624 Cycle 76, year 35 (Wu-Xu), month 5 (Wu-Wu), day 6 (Wu-Wu)
18980701 Cycle 76, year 35 (Wu-Xu), month 5 (Wu-Wu), day 13 (Yi-Chou)
18980703 Cycle 76, year 35 (Wu-Xu), month 5 (Wu-Wu), day 15 (Ding-Mao)
18980706 Cycle 76, year 35 (Wu-Xu), month 5 (Wu-Wu), day 18 (Geng-Wu)
18980708 Cycle 76, year 35 (Wu-Xu), month 5 (Wu-Wu), day 20 (Ren-Shen)
18980710 Cycle 76, year 35 (Wu-Xu), month 5 (Wu-Wu), day 22 (Jia-Xu)
18980717 Cycle 76, year 35 (Wu-Xu), month 5 (Wu-Wu), day 29 (Xin-Si)




reply via email to

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