搜索了好幾個python實現的萬年歷多有部分時間有問題,好多是來自這個代碼:
代碼如下:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
Usage: ccal Month [4-Digit-Year]
or: ccal 4-Digit-Year Month
This Python script is to show Solar and Lunar calender at the
same time. You need to have Python (2.0 or above) installed.
Acceptable date range: 1900/2 -- 2049/12
Output contains Chinese characters (mainland GB2312 encoding),
must be viewed in a Chinese-enabled system or "cxterm" etc.
programms under UNIX X-Windows.
The major reference for me to compose this program is:
lunar-2.1.tgz (1992), composed by
Fung F. Lee <lee@umunhum.stanford.edu> and
Ricky Yeung <Ricky.Yeung@Eng.Sun.Com> .
And Lee and Yeung refered to:
1. "Zhong1guo2 yin1yang2 ri4yue4 dui4zhao4 wan4nian2li4"
by Lin2 Qi3yuan2. 《中國陰陽日月對照萬年歷》.林
2. "Ming4li3 ge2xin1 zi3ping2 cui4yan2" by Xu2 Le4wu2.
《命理革新子平粹言》.徐
3. Da1zhong4 wan4nian2li4. 《大眾萬年歷》
License:
GNU General Public License (GPL, see http://www.gnu.org).
In short, users are free to use and distribute this program
in whole. If users make revisions and distribute the revised
one, they are required to keep the revised source accessible
to the public.
Version:
0.3.2, Jan/16/2007, according to sprite's information, changed 3 codes:
1954: 0x0a5d0 --> 0x0a5b0, 1956: 0x052d0 --> 0x052b0
1916: 0x0d6a0 --> 0x056a0
0.3.1, Jan/15/2007, changed 1978's code from 0xb5a0 to 0xb6a0.
A young lady's birth day (lunar 1978/8/4) problem reported
on internet -- informed by sprite at linuxsir.org
0.3.0, Sep/25/2006, add coding line, prevent python to report warning
0.2.0, Jan/6/2002, ShengXiao(生肖), lunar leap month(閏月)
added.
0.1.0, Jan/4/2002
--- Changsen Xu <xucs007@yahoo.com>
'''
#Remember, in this program:
# month=0 means Januaray, month=1 means February ...;
# day=0 means the first day of a month, day=1 means the second day,
# so as to ease manipulation of Python lists.
# year=0 is 1900, until the last step to output
daysInSolarMonth= [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
新聞熱點
疑難解答