- 浏览: 9206011 次
- 性别:
- 来自: 上海
最新评论
-
netkongjian:
不错的报表工具知识分享![deyi]
主流报表工具推荐 -
starry8023:
您的博客很有用!而且我也出现了类似的问题,我是在vs上运行的, ...
在VC下配置openGL -
sliuxl:
...
复制表结构 -
DR玫瑰花香:
[color=darkblue][/color][size=m ...
KMP算法深度解析 -
alvin198761:
看看这两个操作系统的历史,就知道了,这个问题没法追究责任,一个 ...
一则旧闻-Linux是UNIX的盗版?SCO的三大漏洞
usingSystem;
namespaceCNCalendar
{
publicclassCNDate
{
privateconstushortSTART_YEAR=1901;
privateconstushortEND_YEAR=2050;
privatestring[]ConstellationName=
{
"白羊座","金牛座","双子座",
"巨蟹座","狮子座","处女座",
"天秤座","天蝎座","射手座",
"摩羯座","水瓶座","双鱼座"};
privatestring[]LunarHolDayName=
{
"小寒","大寒","立春","雨水",
"惊蛰","春分","清明","谷雨",
"立夏","小满","芒种","夏至",
"小暑","大暑","立秋","处暑",
"白露","秋分","寒露","霜降",
"立冬","小雪","大雪","冬至"};
//数组gLunarDay存入阴历1901年到2100年每年中的月天数信息,
//阴历每月只能是29或30天,一年用12(或13)个二进制位表示,对应位为1表30天,否则为29天
privateint[]gLunarMonthDay={
//测试数据只有1901.1.1--2050.12.31
0x4ae0,0xa570,0x5268,0xd260,0xd950,0x6aa8,0x56a0,0x9ad0,0x4ae8,0x4ae0,//1910
0xa4d8,0xa4d0,0xd250,0xd548,0xb550,0x56a0,0x96d0,0x95b0,0x49b8,0x49b0,//1920
0xa4b0,0xb258,0x6a50,0x6d40,0xada8,0x2b60,0x9570,0x4978,0x4970,0x64b0,//1930
0xd4a0,0xea50,0x6d48,0x5ad0,0x2b60,0x9370,0x92e0,0xc968,0xc950,0xd4a0,//1940
0xda50,0xb550,0x56a0,0xaad8,0x25d0,0x92d0,0xc958,0xa950,0xb4a8,0x6ca0,//1950
0xb550,0x55a8,0x4da0,0xa5b0,0x52b8,0x52b0,0xa950,0xe950,0x6aa0,0xad50,//1960
0xab50,0x4b60,0xa570,0xa570,0x5260,0xe930,0xd950,0x5aa8,0x56a0,0x96d0,//1970
0x4ae8,0x4ad0,0xa4d0,0xd268,0xd250,0xd528,0xb540,0xb6a0,0x96d0,0x95b0,//1980
0x49b0,0xa4b8,0xa4b0,0xb258,0x6a50,0x6d40,0xada0,0xab60,0x9370,0x4978,//1990
0x4970,0x64b0,0x6a50,0xea50,0x6b28,0x5ac0,0xab60,0x9368,0x92e0,0xc960,//2000
0xd4a8,0xd4a0,0xda50,0x5aa8,0x56a0,0xaad8,0x25d0,0x92d0,0xc958,0xa950,//2010
0xb4a0,0xb550,0xb550,0x55a8,0x4ba0,0xa5b0,0x52b8,0x52b0,0xa930,0x74a8,//2020
0x6aa0,0xad50,0x4da8,0x4b60,0x9570,0xa4e0,0xd260,0xe930,0xd530,0x5aa0,//2030
0x6b50,0x96d0,0x4ae8,0x4ad0,0xa4d0,0xd258,0xd250,0xd520,0xdaa0,0xb5a0,//2040
0x56d0,0x4ad8,0x49b0,0xa4b8,0xa4b0,0xaa50,0xb528,0x6d20,0xada0,0x55b0};//2050
//数组gLanarMonth存放阴历1901年到2050年闰月的月份,如没有则为0,每字节存两年
byte[]gLunarMonth={
0x00,0x50,0x04,0x00,0x20,//1910
0x60,0x05,0x00,0x20,0x70,//1920
0x05,0x00,0x40,0x02,0x06,//1930
0x00,0x50,0x03,0x07,0x00,//1940
0x60,0x04,0x00,0x20,0x70,//1950
0x05,0x00,0x30,0x80,0x06,//1960
0x00,0x40,0x03,0x07,0x00,//1970
0x50,0x04,0x08,0x00,0x60,//1980
0x04,0x0a,0x00,0x60,0x05,//1990
0x00,0x30,0x80,0x05,0x00,//2000
0x40,0x02,0x07,0x00,0x50,//2010
0x04,0x09,0x00,0x60,0x04,//2020
0x00,0x20,0x60,0x05,0x00,//2030
0x30,0xb0,0x06,0x00,0x50,//2040
0x02,0x07,0x00,0x50,0x03};//2050
//数组gLanarHoliDay存放每年的二十四节气对应的阳历日期
//每年的二十四节气对应的阳历日期几乎固定,平均分布于十二个月中
//1月2月3月4月5月6月
//小寒大寒立春雨水惊蛰春分清明谷雨立夏小满芒种夏至
//7月8月9月10月11月12月
//小暑大暑立秋处暑白露秋分寒露霜降立冬小雪大雪冬至
//*********************************************************************************
//节气无任何确定规律,所以只好存表,要节省空间,所以....
//**********************************************************************************}
//数据格式说明:
//如1901年的节气为
//1月2月3月4月5月6月7月8月9月10月11月12月
//6,21,4,19,6,21,5,21,6,22,6,22,8,23,8,24,8,24,8,24,8,23,8,22
//9,6,11,4,9,6,10,6,9,7,9,7,7,8,7,9,7,9,7,9,7,8,7,15
//上面第一行数据为每月节气对应日期,15减去每月第一个节气,每月第二个节气减去15得第二行
//这样每月两个节气对应数据都小于16,每月用一个字节存放,高位存放第一个节气数据,低位存放
//第二个节气的数据,可得下表
byte[]gLunarHolDay={
0x96,0xB4,0x96,0xA6,0x97,0x97,0x78,0x79,0x79,0x69,0x78,0x77,//1901
0x96,0xA4,0x96,0x96,0x97,0x87,0x79,0x79,0x79,0x69,0x78,0x78,//1902
0x96,0xA5,0x87,0x96,0x87,0x87,0x79,0x69,0x69,0x69,0x78,0x78,//1903
0x86,0xA5,0x96,0xA5,0x96,0x97,0x88,0x78,0x78,0x79,0x78,0x87,//1904
0x96,0xB4,0x96,0xA6,0x97,0x97,0x78,0x79,0x79,0x69,0x78,0x77,//1905
0x96,0xA4,0x96,0x96,0x97,0x97,0x79,0x79,0x79,0x69,0x78,0x78,//1906
0x96,0xA5,0x87,0x96,0x87,0x87,0x79,0x69,0x69,0x69,0x78,0x78,//1907
0x86,0xA5,0x96,0xA5,0x96,0x97,0x88,0x78,0x78,0x69,0x78,0x87,//1908
0x96,0xB4,0x96,0xA6,0x97,0x97,0x78,0x79,0x79,0x69,0x78,0x77,//1909
0x96,0xA4,0x96,0x96,0x97,0x97,0x79,0x79,0x79,0x69,0x78,0x78,//1910
0x96,0xA5,0x87,0x96,0x87,0x87,0x79,0x69,0x69,0x69,0x78,0x78,//1911
0x86,0xA5,0x96,0xA5,0x96,0x97,0x88,0x78,0x78,0x69,0x78,0x87,//1912
0x95,0xB4,0x96,0xA6,0x97,0x97,0x78,0x79,0x79,0x69,0x78,0x77,//1913
0x96,0xB4,0x96,0xA6,0x97,0x97,0x79,0x79,0x79,0x69,0x78,0x78,//1914
0x96,0xA5,0x97,0x96,0x97,0x87,0x79,0x79,0x69,0x69,0x78,0x78,//1915
0x96,0xA5,0x96,0xA5,0x96,0x97,0x88,0x78,0x78,0x79,0x77,0x87,//1916
0x95,0xB4,0x96,0xA6,0x96,0x97,0x78,0x79,0x78,0x69,0x78,0x87,//1917
0x96,0xB4,0x96,0xA6,0x97,0x97,0x79,0x79,0x79,0x69,0x78,0x77,//1918
0x96,0xA5,0x97,0x96,0x97,0x87,0x79,0x79,0x69,0x69,0x78,0x78,//1919
0x96,0xA5,0x96,0xA5,0x96,0x97,0x88,0x78,0x78,0x79,0x77,0x87,//1920
0x95,0xB4,0x96,0xA5,0x96,0x97,0x78,0x79,0x78,0x69,0x78,0x87,//1921
0x96,0xB4,0x96,0xA6,0x97,0x97,0x79,0x79,0x79,0x69,0x78,0x77,//1922
0x96,0xA4,0x96,0x96,0x97,0x87,0x79,0x79,0x69,0x69,0x78,0x78,//1923
0x96,0xA5,0x96,0xA5,0x96,0x97,0x88,0x78,0x78,0x79,0x77,0x87,//1924
0x95,0xB4,0x96,0xA5,0x96,0x97,0x78,0x79,0x78,0x69,0x78,0x87,//1925
0x96,0xB4,0x96,0xA6,0x97,0x97,0x78,0x79,0x79,0x69,0x78,0x77,//1926
0x96,0xA4,0x96,0x96,0x97,0x87,0x79,0x79,0x79,0x69,0x78,0x78,//1927
0x96,0xA5,0x96,0xA5,0x96,0x96,0x88,0x78,0x78,0x78,0x87,0x87,//1928
0x95,0xB4,0x96,0xA5,0x96,0x97,0x88,0x78,0x78,0x79,0x77,0x87,//1929
0x96,0xB4,0x96,0xA6,0x97,0x97,0x78,0x79,0x79,0x69,0x78,0x77,//1930
0x96,0xA4,0x96,0x96,0x97,0x87,0x79,0x79,0x79,0x69,0x78,0x78,//1931
0x96,0xA5,0x96,0xA5,0x96,0x96,0x88,0x78,0x78,0x78,0x87,0x87,//1932
0x95,0xB4,0x96,0xA5,0x96,0x97,0x88,0x78,0x78,0x69,0x78,0x87,//1933
0x96,0xB4,0x96,0xA6,0x97,0x97,0x78,0x79,0x79,0x69,0x78,0x77,//1934
0x96,0xA4,0x96,0x96,0x97,0x97,0x79,0x79,0x79,0x69,0x78,0x78,//1935
0x96,0xA5,0x96,0xA5,0x96,0x96,0x88,0x78,0x78,0x78,0x87,0x87,//1936
0x95,0xB4,0x96,0xA5,0x96,0x97,0x88,0x78,0x78,0x69,0x78,0x87,//1937
0x96,0xB4,0x96,0xA6,0x97,0x97,0x78,0x79,0x79,0x69,0x78,0x77,//1938
0x96,0xA4,0x96,0x96,0x97,0x97,0x79,0x79,0x79,0x69,0x78,0x78,//1939
0x96,0xA5,0x96,0xA5,0x96,0x96,0x88,0x78,0x78,0x78,0x87,0x87,//1940
0x95,0xB4,0x96,0xA5,0x96,0x97,0x88,0x78,0x78,0x69,0x78,0x87,//1941
0x96,0xB4,0x96,0xA6,0x97,0x97,0x78,0x79,0x79,0x69,0x78,0x77,//1942
0x96,0xA4,0x96,0x96,0x97,0x97,0x79,0x79,0x79,0x69,0x78,0x78,//1943
0x96,0xA5,0x96,0xA5,0xA6,0x96,0x88,0x78,0x78,0x78,0x87,0x87,//1944
0x95,0xB4,0x96,0xA5,0x96,0x97,0x88,0x78,0x78,0x79,0x77,0x87,//1945
0x95,0xB4,0x96,0xA6,0x97,0x97,0x78,0x79,0x78,0x69,0x78,0x77,//1946
0x96,0xB4,0x96,0xA6,0x97,0x97,0x79,0x79,0x79,0x69,0x78,0x78,//1947
0x96,0xA5,0xA6,0xA5,0xA6,0x96,0x88,0x88,0x78,0x78,0x87,0x87,//1948
0xA5,0xB4,0x96,0xA5,0x96,0x97,0x88,0x79,0x78,0x79,0x77,0x87,//1949
0x95,0xB4,0x96,0xA5,0x96,0x97,0x78,0x79,0x78,0x69,0x78,0x77,//1950
0x96,0xB4,0x96,0xA6,0x97,0x97,0x79,0x79,0x79,0x69,0x78,0x78,//1951
0x96,0xA5,0xA6,0xA5,0xA6,0x96,0x88,0x88,0x78,0x78,0x87,0x87,//1952
0xA5,0xB4,0x96,0xA5,0x96,0x97,0x88,0x78,0x78,0x79,0x77,0x87,//1953
0x95,0xB4,0x96,0xA5,0x96,0x97,0x78,0x79,0x78,0x68,0x78,0x87,//1954
0x96,0xB4,0x96,0xA6,0x97,0x97,0x78,0x79,0x79,0x69,0x78,0x77,//1955
0x96,0xA5,0xA5,0xA5,0xA6,0x96,0x88,0x88,0x78,0x78,0x87,0x87,//1956
0xA5,0xB4,0x96,0xA5,0x96,0x97,0x88,0x78,0x78,0x79,0x77,0x87,//1957
0x95,0xB4,0x96,0xA5,0x96,0x97,0x88,0x78,0x78,0x69,0x78,0x87,//1958
0x96,0xB4,0x96,0xA6,0x97,0x97,0x78,0x79,0x79,0x69,0x78,0x77,//1959
0x96,0xA4,0xA5,0xA5,0xA6,0x96,0x88,0x88,0x88,0x78,0x87,0x87,//1960
0xA5,0xB4,0x96,0xA5,0x96,0x96,0x88,0x78,0x78,0x78,0x87,0x87,//1961
0x96,0xB4,0x96,0xA5,0x96,0x97,0x88,0x78,0x78,0x69,0x78,0x87,//1962
0x96,0xB4,0x96,0xA6,0x97,0x97,0x78,0x79,0x79,0x69,0x78,0x77,//1963
0x96,0xA4,0xA5,0xA5,0xA6,0x96,0x88,0x88,0x88,0x78,0x87,0x87,//1964
0xA5,0xB4,0x96,0xA5,0x96,0x96,0x88,0x78,0x78,0x78,0x87,0x87,//1965
0x95,0xB4,0x96,0xA5,0x96,0x97,0x88,0x78,0x78,0x69,0x78,0x87,//1966
0x96,0xB4,0x96,0xA6,0x97,0x97,0x78,0x79,0x79,0x69,0x78,0x77,//1967
0x96,0xA4,0xA5,0xA5,0xA6,0xA6,0x88,0x88,0x88,0x78,0x87,0x87,//1968
0xA5,0xB4,0x96,0xA5,0x96,0x96,0x88,0x78,0x78,0x78,0x87,0x87,//1969
0x95,0xB4,0x96,0xA5,0x96,0x97,0x88,0x78,0x78,0x69,0x78,0x87,//1970
0x96,0xB4,0x96,0xA6,0x97,0x97,0x78,0x79,0x79,0x69,0x78,0x77,//1971
0x96,0xA4,0xA5,0xA5,0xA6,0xA6,0x88,0x88,0x88,0x78,0x87,0x87,//1972
0xA5,0xB5,0x96,0xA5,0xA6,0x96,0x88,0x78,0x78,0x78,0x87,0x87,//1973
0x95,0xB4,0x96,0xA5,0x96,0x97,0x88,0x78,0x78,0x69,0x78,0x87,//1974
0x96,0xB4,0x96,0xA6,0x97,0x97,0x78,0x79,0x78,0x69,0x78,0x77,//1975
0x96,0xA4,0xA5,0xB5,0xA6,0xA6,0x88,0x89,0x88,0x78,0x87,0x87,//1976
0xA5,0xB4,0x96,0xA5,0x96,0x96,0x88,0x88,0x78,0x78,0x87,0x87,//1977
0x95,0xB4,0x96,0xA5,0x96,0x97,0x88,0x78,0x78,0x79,0x78,0x87,//1978
0x96,0xB4,0x96,0xA6,0x96,0x97,0x78,0x79,0x78,0x69,0x78,0x77,//1979
0x96,0xA4,0xA5,0xB5,0xA6,0xA6,0x88,0x88,0x88,0x78,0x87,0x87,//1980
0xA5,0xB4,0x96,0xA5,0xA6,0x96,0x88,0x88,0x78,0x78,0x77,0x87,//1981
0x95,0xB4,0x96,0xA5,0x96,0x97,0x88,0x78,0x78,0x79,0x77,0x87,//1982
0x95,0xB4,0x96,0xA5,0x96,0x97,0x78,0x79,0x78,0x69,0x78,0x77,//1983
0x96,0xB4,0xA5,0xB5,0xA6,0xA6,0x87,0x88,0x88,0x78,0x87,0x87,//1984
0xA5,0xB4,0xA6,0xA5,0xA6,0x96,0x88,0x88,0x78,0x78,0x87,0x87,//1985
0xA5,0xB4,0x96,0xA5,0x96,0x97,0x88,0x78,0x78,0x79,0x77,0x87,//1986
0x95,0xB4,0x96,0xA5,0x96,0x97,0x88,0x79,0x78,0x69,0x78,0x87,//1987
0x96,0xB4,0xA5,0xB5,0xA6,0xA6,0x87,0x88,0x88,0x78,0x87,0x86,//1988
0xA5,0xB4,0xA5,0xA5,0xA6,0x96,0x88,0x88,0x88,0x78,0x87,0x87,//1989
0xA5,0xB4,0x96,0xA5,0x96,0x96,0x88,0x78,0x78,0x79,0x77,0x87,//1990
0x95,0xB4,0x96,0xA5,0x86,0x97,0x88,0x78,0x78,0x69,0x78,0x87,//1991
0x96,0xB4,0xA5,0xB5,0xA6,0xA6,0x87,0x88,0x88,0x78,0x87,0x86,//1992
0xA5,0xB3,0xA5,0xA5,0xA6,0x96,0x88,0x88,0x88,0x78,0x87,0x87,//1993
0xA5,0xB4,0x96,0xA5,0x96,0x96,0x88,0x78,0x78,0x78,0x87,0x87,//1994
0x95,0xB4,0x96,0xA5,0x96,0x97,0x88,0x76,0x78,0x69,0x78,0x87,//1995
0x96,0xB4,0xA5,0xB5,0xA6,0xA6,0x87,0x88,0x88,0x78,0x87,0x86,//1996
0xA5,0xB3,0xA5,0xA5,0xA6,0xA6,0x88,0x88,0x88,0x78,0x87,0x87,//1997
0xA5,0xB4,0x96,0xA5,0x96,0x96,0x88,0x78,0x78,0x78,0x87,0x87,//1998
0x95,0xB4,0x96,0xA5,0x96,0x97,0x88,0x78,0x78,0x69,0x78,0x87,//1999
0x96,0xB4,0xA5,0xB5,0xA6,0xA6,0x87,0x88,0x88,0x78,0x87,0x86,//2000
0xA5,0xB3,0xA5,0xA5,0xA6,0xA6,0x88,0x88,0x88,0x78,0x87,0x87,//2001
0xA5,0xB4,0x96,0xA5,0x96,0x96,0x88,0x78,0x78,0x78,0x87,0x87,//2002
0x95,0xB4,0x96,0xA5,0x96,0x97,0x88,0x78,0x78,0x69,0x78,0x87,//2003
0x96,0xB4,0xA5,0xB5,0xA6,0xA6,0x87,0x88,0x88,0x78,0x87,0x86,//2004
0xA5,0xB3,0xA5,0xA5,0xA6,0xA6,0x88,0x88,0x88,0x78,0x87,0x87,//2005
0xA5,0xB4,0x96,0xA5,0xA6,0x96,0x88,0x88,0x78,0x78,0x87,0x87,//2006
0x95,0xB4,0x96,0xA5,0x96,0x97,0x88,0x78,0x78,0x69,0x78,0x87,//2007
0x96,0xB4,0xA5,0xB5,0xA6,0xA6,0x87,0x88,0x87,0x78,0x87,0x86,//2008
0xA5,0xB3,0xA5,0xB5,0xA6,0xA6,0x88,0x88,0x88,0x78,0x87,0x87,//2009
0xA5,0xB4,0x96,0xA5,0xA6,0x96,0x88,0x88,0x78,0x78,0x87,0x87,//2010
0x95,0xB4,0x96,0xA5,0x96,0x97,0x88,0x78,0x78,0x79,0x78,0x87,//2011
0x96,0xB4,0xA5,0xB5,0xA5,0xA6,0x87,0x88,0x87,0x78,0x87,0x86,//2012
0xA5,0xB3,0xA5,0xB5,0xA6,0xA6,0x87,0x88,0x88,0x78,0x87,0x87,//2013
0xA5,0xB4,0x96,0xA5,0xA6,0x96,0x88,0x88,0x78,0x78,0x87,0x87,//2014
0x95,0xB4,0x96,0xA5,0x96,0x97,0x88,0x78,0x78,0x79,0x77,0x87,//2015
0x95,0xB4,0xA5,0xB4,0xA5,0xA6,0x87,0x88,0x87,0x78,0x87,0x86,//2016
0xA5,0xC3,0xA5,0xB5,0xA6,0xA6,0x87,0x88,0x88,0x78,0x87,0x87,//2017
0xA5,0xB4,0xA6,0xA5,0xA6,0x96,0x88,0x88,0x78,0x78,0x87,0x87,//2018
0xA5,0xB4,0x96,0xA5,0x96,0x96,0x88,0x78,0x78,0x79,0x77,0x87,//2019
0x95,0xB4,0xA5,0xB4,0xA5,0xA6,0x97,0x87,0x87,0x78,0x87,0x86,//2020
0xA5,0xC3,0xA5,0xB5,0xA6,0xA6,0x87,0x88,0x88,0x78,0x87,0x86,//2021
0xA5,0xB4,0xA5,0xA5,0xA6,0x96,0x88,0x88,0x88,0x78,0x87,0x87,//2022
0xA5,0xB4,0x96,0xA5,0x96,0x96,0x88,0x78,0x78,0x79,0x77,0x87,//2023
0x95,0xB4,0xA5,0xB4,0xA5,0xA6,0x97,0x87,0x87,0x78,0x87,0x96,//2024
0xA5,0xC3,0xA5,0xB5,0xA6,0xA6,0x87,0x88,0x88,0x78,0x87,0x86,//2025
0xA5,0xB3,0xA5,0xA5,0xA6,0xA6,0x88,0x88,0x88,0x78,0x87,0x87,//2026
0xA5,0xB4,0x96,0xA5,0x96,0x96,0x88,0x78,0x78,0x78,0x87,0x87,//2027
0x95,0xB4,0xA5,0xB4,0xA5,0xA6,0x97,0x87,0x87,0x78,0x87,0x96,//2028
0xA5,0xC3,0xA5,0xB5,0xA6,0xA6,0x87,0x88,0x88,0x78,0x87,0x86,//2029
0xA5,0xB3,0xA5,0xA5,0xA6,0xA6,0x88,0x88,0x88,0x78,0x87,0x87,//2030
0xA5,0xB4,0x96,0xA5,0x96,0x96,0x88,0x78,0x78,0x78,0x87,0x87,//2031
0x95,0xB4,0xA5,0xB4,0xA5,0xA6,0x97,0x87,0x87,0x78,0x87,0x96,//2032
0xA5,0xC3,0xA5,0xB5,0xA6,0xA6,0x88,0x88,0x88,0x78,0x87,0x86,//2033
0xA5,0xB3,0xA5,0xA5,0xA6,0xA6,0x88,0x78,0x88,0x78,0x87,0x87,//2034
0xA5,0xB4,0x96,0xA5,0xA6,0x96,0x88,0x88,0x78,0x78,0x87,0x87,//2035
0x95,0xB4,0xA5,0xB4,0xA5,0xA6,0x97,0x87,0x87,0x78,0x87,0x96,//2036
0xA5,0xC3,0xA5,0xB5,0xA6,0xA6,0x87,0x88,0x88,0x78,0x87,0x86,//2037
0xA5,0xB3,0xA5,0xA5,0xA6,0xA6,0x88,0x88,0x88,0x78,0x87,0x87,//2038
0xA5,0xB4,0x96,0xA5,0xA6,0x96,0x88,0x88,0x78,0x78,0x87,0x87,//2039
0x95,0xB4,0xA5,0xB4,0xA5,0xA6,0x97,0x87,0x87,0x78,0x87,0x96,//2040
0xA5,0xC3,0xA5,0xB5,0xA5,0xA6,0x87,0x88,0x87,0x78,0x87,0x86,//2041
0xA5,0xB3,0xA5,0xB5,0xA6,0xA6,0x88,0x88,0x88,0x78,0x87,0x87,//2042
0xA5,0xB4,0x96,0xA5,0xA6,0x96,0x88,0x88,0x78,0x78,0x87,0x87,//2043
0x95,0xB4,0xA5,0xB4,0xA5,0xA6,0x97,0x87,0x87,0x88,0x87,0x96,//2044
0xA5,0xC3,0xA5,0xB4,0xA5,0xA6,0x87,0x88,0x87,0x78,0x87,0x86,//2045
0xA5,0xB3,0xA5,0xB5,0xA6,0xA6,0x87,0x88,0x88,0x78,0x87,0x87,//2046
0xA5,0xB4,0x96,0xA5,0xA6,0x96,0x88,0x88,0x78,0x78,0x87,0x87,//2047
0x95,0xB4,0xA5,0xB4,0xA5,0xA5,0x97,0x87,0x87,0x88,0x86,0x96,//2048
0xA4,0xC3,0xA5,0xA5,0xA5,0xA6,0x97,0x87,0x87,0x78,0x87,0x86,//2049
0xA5,0xC3,0xA5,0xB5,0xA6,0xA6,0x87,0x88,0x78,0x78,0x87,0x87};//2050
privateDateTimem_Date;
publicDateTimeDate
{
get{returnm_Date;}
set{m_Date=value;}
}
publicCNDate()
{
Date=DateTime.Today;
}
publicCNDate(DateTimedt)
{
Date=dt.Date;
}
//计算指定日期的星座序号
publicintGetConstellation()
{
intY,M,D;
Y=m_Date.Year;
M=m_Date.Month;
D=m_Date.Day;
Y=M*100+D;
if(((Y>=321)&&(Y<=419))){return0;}
elseif((Y>=420)&&(Y<=520)){return1;}
elseif((Y>=521)&&(Y<=620)){return2;}
elseif((Y>=621)&&(Y<=722)){return3;}
elseif((Y>=723)&&(Y<=822)){return4;}
elseif((Y>=823)&&(Y<=922)){return5;}
elseif((Y>=923)&&(Y<=1022)){return6;}
elseif((Y>=1023)&&(Y<=1121)){return7;}
elseif((Y>=1122)&&(Y<=1221)){return8;}
elseif((Y>=1222)||(Y<=119)){return9;}
elseif((Y>=120)&&(Y<=218)){return10;}
elseif((Y>=219)&&(Y<=320)){return11;}
else{return-1;};
}
//计算指定日期的星座名称
publicstringGetConstellationName()
{
intConstellation;
Constellation=GetConstellation();
if((Constellation>=0)&&(Constellation<=11))
{returnConstellationName[Constellation];}
else
{return"";};
}
//计算公历当天对应的节气0-23,-1表示不是节气
publicintl_GetLunarHolDay()
{
byteFlag;
intDay,iYear,iMonth,iDay;
iYear=m_Date.Year;
if((iYear<START_YEAR)||(iYear>END_YEAR))
{return-1;};
iMonth=m_Date.Month;
iDay=m_Date.Day;
Flag=gLunarHolDay[(iYear-START_YEAR)*12+iMonth-1];
if(iDay<15)
{Day=15-((Flag>>4)&0x0f);}
else
{Day=(Flag&0x0f)+15;};
if(iDay==Day)
{
if(iDay>15)
{return(iMonth-1)*2+1;}
else
{return(iMonth-1)*2;}
}
else
{return-1;};
}
publicstringFormatMonth(ushortiMonth,boolbLunar)
{
stringszText="正二三四五六七八九十";
stringstrMonth;
if((!bLunar)&&(iMonth==1))
{return"一月";}
if(iMonth<=10)
{
strMonth="";
strMonth=strMonth+szText.Substring(iMonth-1,1);
strMonth=strMonth+"月";
returnstrMonth;
}
if(iMonth==11)
{strMonth="十一";}
else
{strMonth="十二";}
returnstrMonth+"月";
}
publicstringFormatLunarDay(ushortiDay)
{
stringszText1="初十廿三";
stringszText2="一二三四五六七八九十";
stringstrDay;
if((iDay!=20)&&(iDay!=30))
{
strDay=szText1.Substring((iDay-1)/10,1);
strDay=strDay+szText2.Substring((iDay-1)%10,1);
}
else
{
strDay=szText1.Substring((iDay/10)*2+1,2);
strDay=strDay+"十";
}
returnstrDay;
}
publicstringGetLunarHolDay()
{
ushortiYear,iMonth,iDay;
inti;
TimeSpants;
iYear=(ushort)(m_Date.Year);
if((iYear<START_YEAR)||(iYear>END_YEAR))
{return"";};
i=l_GetLunarHolDay();
if((i>=0)&&(i<=23))
{returnLunarHolDayName[i];}
else
{
ts=m_Date-(newDateTime(START_YEAR,1,1));
l_CalcLunarDate(outiYear,outiMonth,outiDay,(uint)(ts.Days));
returnFormatMonth(iMonth,true)+FormatLunarDay(iDay);
}
}
//返回阴历iLunarYear年的闰月月份,如没有返回01901年1月---2050年12月
publicintGetLeapMonth(ushortiLunarYear)
{
byteFlag;
if((iLunarYear<START_YEAR)||(iLunarYear>END_YEAR))
{return0;};
Flag=gLunarMonth[(iLunarYear-START_YEAR)/2];
if((iLunarYear-START_YEAR)%2==0)
{returnFlag>>4;}
else
{returnFlag&0x0F;}
}
//返回阴历iLunarYer年阴历iLunarMonth月的天数,如果iLunarMonth为闰月,
//高字为第二个iLunarMonth月的天数,否则高字为01901年1月---2050年12月
publicuintLunarMonthDays(ushortiLunarYear,ushortiLunarMonth)
{
intHeight,Low;
intiBit;
if((iLunarYear<START_YEAR)||(iLunarYear>END_YEAR))
{return30;}
Height=0;
Low=29;
iBit=16-iLunarMonth;
if((iLunarMonth>GetLeapMonth(iLunarYear))&&(GetLeapMonth(iLunarYear)>0))
{iBit--;}
if((gLunarMonthDay[iLunarYear-START_YEAR]&(1<<iBit))>0)
{Low++;}
if(iLunarMonth==GetLeapMonth(iLunarYear))
{
if((gLunarMonthDay[iLunarYear-START_YEAR]&(1<<(iBit-1)))>0)
{Height=30;}
else
{Height=29;}
}
return(uint)((uint)(Low)|(uint)(Height)<<16);//合成为uint
}
//返回阴历iLunarYear年的总天数1901年1月---2050年12月
publicintLunarYearDays(ushortiLunarYear)
{
intDays;
uinttmp;
if((iLunarYear<START_YEAR)||(iLunarYear>END_YEAR))
{return0;};
Days=0;
for(ushorti=1;i<=12;i++)
{
tmp=LunarMonthDays(iLunarYear,i);
Days=Days+((ushort)(tmp>>16)&0xFFFF);//取高位
Days=Days+(ushort)(tmp);//取低位
}
returnDays;
}
//计算从1901年1月1日过iSpanDays天后的阴历日期
publicvoidl_CalcLunarDate(outushortiYear,outushortiMonth,outushortiDay,uintiSpanDays)
{
uinttmp;
//阳历1901年2月19日为阴历1901年正月初一
//阳历1901年1月1日到2月19日共有49天
if(iSpanDays<49)
{
iYear=START_YEAR-1;
if(iSpanDays<19)
{
iMonth=11;
iDay=(ushort)(11+iSpanDays);
}
else
{
iMonth=12;
iDay=(ushort)(iSpanDays-18);
}
return;
}
//下面从阴历1901年正月初一算起
iSpanDays=iSpanDays-49;
iYear=START_YEAR;
iMonth=1;
iDay=1;
//计算年
tmp=(uint)LunarYearDays(iYear);
while(iSpanDays>=tmp)
{
iSpanDays=iSpanDays-tmp;
iYear++;
tmp=(uint)LunarYearDays(iYear);
}
//计算月
tmp=LunarMonthDays(iYear,iMonth);//取低位
while(iSpanDays>=tmp)
{
iSpanDays=iSpanDays-tmp;
if(iMonth==GetLeapMonth(iYear))
{
tmp=(LunarMonthDays(iYear,iMonth)>>16)&0xFFFF;//取高位
if(iSpanDays<tmp)
{break;}
iSpanDays=iSpanDays-tmp;
}
iMonth++;
tmp=LunarMonthDays(iYear,iMonth);//取低位
}
//计算日
iDay=(ushort)(iDay+iSpanDays);
}
//把iYear年格式化成天干记年法表示的字符串
publicstringFormatLunarYear()
{
stringstrYear;
stringszText1="甲乙丙丁戊己庚辛壬癸";
stringszText2="子丑寅卯辰巳午未申酉戌亥";
stringszText3="鼠牛虎免龙蛇马羊猴鸡狗猪";
ushortiYear;
iYear=(ushort)(m_Date.Year);
strYear=szText1.Substring((iYear-4)%10,1);
strYear=strYear+szText2.Substring((iYear-4)%12,1);
strYear=strYear+"";
strYear=strYear+szText3.Substring((iYear-4)%12,1);
strYear=strYear+"年";
returnstrYear;
}
}//classCNDate
publicclassTest
{
staticvoidMain(string[]args)
{
CNDatedt=newCNDate(DateTime.Today);
Console.WriteLine("今天是:"+dt.Date.ToString()+dt.GetConstellationName());
Console.WriteLine(dt.l_GetLunarHolDay());
Console.WriteLine(dt.GetLunarHolDay());
Console.WriteLine("闰月"+dt.GetLeapMonth(UInt16.Parse(args[0])));
Console.WriteLine("2月的天数"+dt.LunarMonthDays(UInt16.Parse(args[0]),UInt16.Parse(args[1])));
Console.WriteLine("天数"+dt.LunarYearDays(UInt16.Parse(args[0])));
Console.WriteLine(""+dt.FormatLunarYear());
dt.Date=DateTime.Today.AddDays(1);
Console.WriteLine("明天是:"+dt.Date.ToString()+dt.GetConstellationName());
}
}//classTest
}
namespaceCNCalendar
{
publicclassCNDate
{
privateconstushortSTART_YEAR=1901;
privateconstushortEND_YEAR=2050;
privatestring[]ConstellationName=
{
"白羊座","金牛座","双子座",
"巨蟹座","狮子座","处女座",
"天秤座","天蝎座","射手座",
"摩羯座","水瓶座","双鱼座"};
privatestring[]LunarHolDayName=
{
"小寒","大寒","立春","雨水",
"惊蛰","春分","清明","谷雨",
"立夏","小满","芒种","夏至",
"小暑","大暑","立秋","处暑",
"白露","秋分","寒露","霜降",
"立冬","小雪","大雪","冬至"};
//数组gLunarDay存入阴历1901年到2100年每年中的月天数信息,
//阴历每月只能是29或30天,一年用12(或13)个二进制位表示,对应位为1表30天,否则为29天
privateint[]gLunarMonthDay={
//测试数据只有1901.1.1--2050.12.31
0x4ae0,0xa570,0x5268,0xd260,0xd950,0x6aa8,0x56a0,0x9ad0,0x4ae8,0x4ae0,//1910
0xa4d8,0xa4d0,0xd250,0xd548,0xb550,0x56a0,0x96d0,0x95b0,0x49b8,0x49b0,//1920
0xa4b0,0xb258,0x6a50,0x6d40,0xada8,0x2b60,0x9570,0x4978,0x4970,0x64b0,//1930
0xd4a0,0xea50,0x6d48,0x5ad0,0x2b60,0x9370,0x92e0,0xc968,0xc950,0xd4a0,//1940
0xda50,0xb550,0x56a0,0xaad8,0x25d0,0x92d0,0xc958,0xa950,0xb4a8,0x6ca0,//1950
0xb550,0x55a8,0x4da0,0xa5b0,0x52b8,0x52b0,0xa950,0xe950,0x6aa0,0xad50,//1960
0xab50,0x4b60,0xa570,0xa570,0x5260,0xe930,0xd950,0x5aa8,0x56a0,0x96d0,//1970
0x4ae8,0x4ad0,0xa4d0,0xd268,0xd250,0xd528,0xb540,0xb6a0,0x96d0,0x95b0,//1980
0x49b0,0xa4b8,0xa4b0,0xb258,0x6a50,0x6d40,0xada0,0xab60,0x9370,0x4978,//1990
0x4970,0x64b0,0x6a50,0xea50,0x6b28,0x5ac0,0xab60,0x9368,0x92e0,0xc960,//2000
0xd4a8,0xd4a0,0xda50,0x5aa8,0x56a0,0xaad8,0x25d0,0x92d0,0xc958,0xa950,//2010
0xb4a0,0xb550,0xb550,0x55a8,0x4ba0,0xa5b0,0x52b8,0x52b0,0xa930,0x74a8,//2020
0x6aa0,0xad50,0x4da8,0x4b60,0x9570,0xa4e0,0xd260,0xe930,0xd530,0x5aa0,//2030
0x6b50,0x96d0,0x4ae8,0x4ad0,0xa4d0,0xd258,0xd250,0xd520,0xdaa0,0xb5a0,//2040
0x56d0,0x4ad8,0x49b0,0xa4b8,0xa4b0,0xaa50,0xb528,0x6d20,0xada0,0x55b0};//2050
//数组gLanarMonth存放阴历1901年到2050年闰月的月份,如没有则为0,每字节存两年
byte[]gLunarMonth={
0x00,0x50,0x04,0x00,0x20,//1910
0x60,0x05,0x00,0x20,0x70,//1920
0x05,0x00,0x40,0x02,0x06,//1930
0x00,0x50,0x03,0x07,0x00,//1940
0x60,0x04,0x00,0x20,0x70,//1950
0x05,0x00,0x30,0x80,0x06,//1960
0x00,0x40,0x03,0x07,0x00,//1970
0x50,0x04,0x08,0x00,0x60,//1980
0x04,0x0a,0x00,0x60,0x05,//1990
0x00,0x30,0x80,0x05,0x00,//2000
0x40,0x02,0x07,0x00,0x50,//2010
0x04,0x09,0x00,0x60,0x04,//2020
0x00,0x20,0x60,0x05,0x00,//2030
0x30,0xb0,0x06,0x00,0x50,//2040
0x02,0x07,0x00,0x50,0x03};//2050
//数组gLanarHoliDay存放每年的二十四节气对应的阳历日期
//每年的二十四节气对应的阳历日期几乎固定,平均分布于十二个月中
//1月2月3月4月5月6月
//小寒大寒立春雨水惊蛰春分清明谷雨立夏小满芒种夏至
//7月8月9月10月11月12月
//小暑大暑立秋处暑白露秋分寒露霜降立冬小雪大雪冬至
//*********************************************************************************
//节气无任何确定规律,所以只好存表,要节省空间,所以....
//**********************************************************************************}
//数据格式说明:
//如1901年的节气为
//1月2月3月4月5月6月7月8月9月10月11月12月
//6,21,4,19,6,21,5,21,6,22,6,22,8,23,8,24,8,24,8,24,8,23,8,22
//9,6,11,4,9,6,10,6,9,7,9,7,7,8,7,9,7,9,7,9,7,8,7,15
//上面第一行数据为每月节气对应日期,15减去每月第一个节气,每月第二个节气减去15得第二行
//这样每月两个节气对应数据都小于16,每月用一个字节存放,高位存放第一个节气数据,低位存放
//第二个节气的数据,可得下表
byte[]gLunarHolDay={
0x96,0xB4,0x96,0xA6,0x97,0x97,0x78,0x79,0x79,0x69,0x78,0x77,//1901
0x96,0xA4,0x96,0x96,0x97,0x87,0x79,0x79,0x79,0x69,0x78,0x78,//1902
0x96,0xA5,0x87,0x96,0x87,0x87,0x79,0x69,0x69,0x69,0x78,0x78,//1903
0x86,0xA5,0x96,0xA5,0x96,0x97,0x88,0x78,0x78,0x79,0x78,0x87,//1904
0x96,0xB4,0x96,0xA6,0x97,0x97,0x78,0x79,0x79,0x69,0x78,0x77,//1905
0x96,0xA4,0x96,0x96,0x97,0x97,0x79,0x79,0x79,0x69,0x78,0x78,//1906
0x96,0xA5,0x87,0x96,0x87,0x87,0x79,0x69,0x69,0x69,0x78,0x78,//1907
0x86,0xA5,0x96,0xA5,0x96,0x97,0x88,0x78,0x78,0x69,0x78,0x87,//1908
0x96,0xB4,0x96,0xA6,0x97,0x97,0x78,0x79,0x79,0x69,0x78,0x77,//1909
0x96,0xA4,0x96,0x96,0x97,0x97,0x79,0x79,0x79,0x69,0x78,0x78,//1910
0x96,0xA5,0x87,0x96,0x87,0x87,0x79,0x69,0x69,0x69,0x78,0x78,//1911
0x86,0xA5,0x96,0xA5,0x96,0x97,0x88,0x78,0x78,0x69,0x78,0x87,//1912
0x95,0xB4,0x96,0xA6,0x97,0x97,0x78,0x79,0x79,0x69,0x78,0x77,//1913
0x96,0xB4,0x96,0xA6,0x97,0x97,0x79,0x79,0x79,0x69,0x78,0x78,//1914
0x96,0xA5,0x97,0x96,0x97,0x87,0x79,0x79,0x69,0x69,0x78,0x78,//1915
0x96,0xA5,0x96,0xA5,0x96,0x97,0x88,0x78,0x78,0x79,0x77,0x87,//1916
0x95,0xB4,0x96,0xA6,0x96,0x97,0x78,0x79,0x78,0x69,0x78,0x87,//1917
0x96,0xB4,0x96,0xA6,0x97,0x97,0x79,0x79,0x79,0x69,0x78,0x77,//1918
0x96,0xA5,0x97,0x96,0x97,0x87,0x79,0x79,0x69,0x69,0x78,0x78,//1919
0x96,0xA5,0x96,0xA5,0x96,0x97,0x88,0x78,0x78,0x79,0x77,0x87,//1920
0x95,0xB4,0x96,0xA5,0x96,0x97,0x78,0x79,0x78,0x69,0x78,0x87,//1921
0x96,0xB4,0x96,0xA6,0x97,0x97,0x79,0x79,0x79,0x69,0x78,0x77,//1922
0x96,0xA4,0x96,0x96,0x97,0x87,0x79,0x79,0x69,0x69,0x78,0x78,//1923
0x96,0xA5,0x96,0xA5,0x96,0x97,0x88,0x78,0x78,0x79,0x77,0x87,//1924
0x95,0xB4,0x96,0xA5,0x96,0x97,0x78,0x79,0x78,0x69,0x78,0x87,//1925
0x96,0xB4,0x96,0xA6,0x97,0x97,0x78,0x79,0x79,0x69,0x78,0x77,//1926
0x96,0xA4,0x96,0x96,0x97,0x87,0x79,0x79,0x79,0x69,0x78,0x78,//1927
0x96,0xA5,0x96,0xA5,0x96,0x96,0x88,0x78,0x78,0x78,0x87,0x87,//1928
0x95,0xB4,0x96,0xA5,0x96,0x97,0x88,0x78,0x78,0x79,0x77,0x87,//1929
0x96,0xB4,0x96,0xA6,0x97,0x97,0x78,0x79,0x79,0x69,0x78,0x77,//1930
0x96,0xA4,0x96,0x96,0x97,0x87,0x79,0x79,0x79,0x69,0x78,0x78,//1931
0x96,0xA5,0x96,0xA5,0x96,0x96,0x88,0x78,0x78,0x78,0x87,0x87,//1932
0x95,0xB4,0x96,0xA5,0x96,0x97,0x88,0x78,0x78,0x69,0x78,0x87,//1933
0x96,0xB4,0x96,0xA6,0x97,0x97,0x78,0x79,0x79,0x69,0x78,0x77,//1934
0x96,0xA4,0x96,0x96,0x97,0x97,0x79,0x79,0x79,0x69,0x78,0x78,//1935
0x96,0xA5,0x96,0xA5,0x96,0x96,0x88,0x78,0x78,0x78,0x87,0x87,//1936
0x95,0xB4,0x96,0xA5,0x96,0x97,0x88,0x78,0x78,0x69,0x78,0x87,//1937
0x96,0xB4,0x96,0xA6,0x97,0x97,0x78,0x79,0x79,0x69,0x78,0x77,//1938
0x96,0xA4,0x96,0x96,0x97,0x97,0x79,0x79,0x79,0x69,0x78,0x78,//1939
0x96,0xA5,0x96,0xA5,0x96,0x96,0x88,0x78,0x78,0x78,0x87,0x87,//1940
0x95,0xB4,0x96,0xA5,0x96,0x97,0x88,0x78,0x78,0x69,0x78,0x87,//1941
0x96,0xB4,0x96,0xA6,0x97,0x97,0x78,0x79,0x79,0x69,0x78,0x77,//1942
0x96,0xA4,0x96,0x96,0x97,0x97,0x79,0x79,0x79,0x69,0x78,0x78,//1943
0x96,0xA5,0x96,0xA5,0xA6,0x96,0x88,0x78,0x78,0x78,0x87,0x87,//1944
0x95,0xB4,0x96,0xA5,0x96,0x97,0x88,0x78,0x78,0x79,0x77,0x87,//1945
0x95,0xB4,0x96,0xA6,0x97,0x97,0x78,0x79,0x78,0x69,0x78,0x77,//1946
0x96,0xB4,0x96,0xA6,0x97,0x97,0x79,0x79,0x79,0x69,0x78,0x78,//1947
0x96,0xA5,0xA6,0xA5,0xA6,0x96,0x88,0x88,0x78,0x78,0x87,0x87,//1948
0xA5,0xB4,0x96,0xA5,0x96,0x97,0x88,0x79,0x78,0x79,0x77,0x87,//1949
0x95,0xB4,0x96,0xA5,0x96,0x97,0x78,0x79,0x78,0x69,0x78,0x77,//1950
0x96,0xB4,0x96,0xA6,0x97,0x97,0x79,0x79,0x79,0x69,0x78,0x78,//1951
0x96,0xA5,0xA6,0xA5,0xA6,0x96,0x88,0x88,0x78,0x78,0x87,0x87,//1952
0xA5,0xB4,0x96,0xA5,0x96,0x97,0x88,0x78,0x78,0x79,0x77,0x87,//1953
0x95,0xB4,0x96,0xA5,0x96,0x97,0x78,0x79,0x78,0x68,0x78,0x87,//1954
0x96,0xB4,0x96,0xA6,0x97,0x97,0x78,0x79,0x79,0x69,0x78,0x77,//1955
0x96,0xA5,0xA5,0xA5,0xA6,0x96,0x88,0x88,0x78,0x78,0x87,0x87,//1956
0xA5,0xB4,0x96,0xA5,0x96,0x97,0x88,0x78,0x78,0x79,0x77,0x87,//1957
0x95,0xB4,0x96,0xA5,0x96,0x97,0x88,0x78,0x78,0x69,0x78,0x87,//1958
0x96,0xB4,0x96,0xA6,0x97,0x97,0x78,0x79,0x79,0x69,0x78,0x77,//1959
0x96,0xA4,0xA5,0xA5,0xA6,0x96,0x88,0x88,0x88,0x78,0x87,0x87,//1960
0xA5,0xB4,0x96,0xA5,0x96,0x96,0x88,0x78,0x78,0x78,0x87,0x87,//1961
0x96,0xB4,0x96,0xA5,0x96,0x97,0x88,0x78,0x78,0x69,0x78,0x87,//1962
0x96,0xB4,0x96,0xA6,0x97,0x97,0x78,0x79,0x79,0x69,0x78,0x77,//1963
0x96,0xA4,0xA5,0xA5,0xA6,0x96,0x88,0x88,0x88,0x78,0x87,0x87,//1964
0xA5,0xB4,0x96,0xA5,0x96,0x96,0x88,0x78,0x78,0x78,0x87,0x87,//1965
0x95,0xB4,0x96,0xA5,0x96,0x97,0x88,0x78,0x78,0x69,0x78,0x87,//1966
0x96,0xB4,0x96,0xA6,0x97,0x97,0x78,0x79,0x79,0x69,0x78,0x77,//1967
0x96,0xA4,0xA5,0xA5,0xA6,0xA6,0x88,0x88,0x88,0x78,0x87,0x87,//1968
0xA5,0xB4,0x96,0xA5,0x96,0x96,0x88,0x78,0x78,0x78,0x87,0x87,//1969
0x95,0xB4,0x96,0xA5,0x96,0x97,0x88,0x78,0x78,0x69,0x78,0x87,//1970
0x96,0xB4,0x96,0xA6,0x97,0x97,0x78,0x79,0x79,0x69,0x78,0x77,//1971
0x96,0xA4,0xA5,0xA5,0xA6,0xA6,0x88,0x88,0x88,0x78,0x87,0x87,//1972
0xA5,0xB5,0x96,0xA5,0xA6,0x96,0x88,0x78,0x78,0x78,0x87,0x87,//1973
0x95,0xB4,0x96,0xA5,0x96,0x97,0x88,0x78,0x78,0x69,0x78,0x87,//1974
0x96,0xB4,0x96,0xA6,0x97,0x97,0x78,0x79,0x78,0x69,0x78,0x77,//1975
0x96,0xA4,0xA5,0xB5,0xA6,0xA6,0x88,0x89,0x88,0x78,0x87,0x87,//1976
0xA5,0xB4,0x96,0xA5,0x96,0x96,0x88,0x88,0x78,0x78,0x87,0x87,//1977
0x95,0xB4,0x96,0xA5,0x96,0x97,0x88,0x78,0x78,0x79,0x78,0x87,//1978
0x96,0xB4,0x96,0xA6,0x96,0x97,0x78,0x79,0x78,0x69,0x78,0x77,//1979
0x96,0xA4,0xA5,0xB5,0xA6,0xA6,0x88,0x88,0x88,0x78,0x87,0x87,//1980
0xA5,0xB4,0x96,0xA5,0xA6,0x96,0x88,0x88,0x78,0x78,0x77,0x87,//1981
0x95,0xB4,0x96,0xA5,0x96,0x97,0x88,0x78,0x78,0x79,0x77,0x87,//1982
0x95,0xB4,0x96,0xA5,0x96,0x97,0x78,0x79,0x78,0x69,0x78,0x77,//1983
0x96,0xB4,0xA5,0xB5,0xA6,0xA6,0x87,0x88,0x88,0x78,0x87,0x87,//1984
0xA5,0xB4,0xA6,0xA5,0xA6,0x96,0x88,0x88,0x78,0x78,0x87,0x87,//1985
0xA5,0xB4,0x96,0xA5,0x96,0x97,0x88,0x78,0x78,0x79,0x77,0x87,//1986
0x95,0xB4,0x96,0xA5,0x96,0x97,0x88,0x79,0x78,0x69,0x78,0x87,//1987
0x96,0xB4,0xA5,0xB5,0xA6,0xA6,0x87,0x88,0x88,0x78,0x87,0x86,//1988
0xA5,0xB4,0xA5,0xA5,0xA6,0x96,0x88,0x88,0x88,0x78,0x87,0x87,//1989
0xA5,0xB4,0x96,0xA5,0x96,0x96,0x88,0x78,0x78,0x79,0x77,0x87,//1990
0x95,0xB4,0x96,0xA5,0x86,0x97,0x88,0x78,0x78,0x69,0x78,0x87,//1991
0x96,0xB4,0xA5,0xB5,0xA6,0xA6,0x87,0x88,0x88,0x78,0x87,0x86,//1992
0xA5,0xB3,0xA5,0xA5,0xA6,0x96,0x88,0x88,0x88,0x78,0x87,0x87,//1993
0xA5,0xB4,0x96,0xA5,0x96,0x96,0x88,0x78,0x78,0x78,0x87,0x87,//1994
0x95,0xB4,0x96,0xA5,0x96,0x97,0x88,0x76,0x78,0x69,0x78,0x87,//1995
0x96,0xB4,0xA5,0xB5,0xA6,0xA6,0x87,0x88,0x88,0x78,0x87,0x86,//1996
0xA5,0xB3,0xA5,0xA5,0xA6,0xA6,0x88,0x88,0x88,0x78,0x87,0x87,//1997
0xA5,0xB4,0x96,0xA5,0x96,0x96,0x88,0x78,0x78,0x78,0x87,0x87,//1998
0x95,0xB4,0x96,0xA5,0x96,0x97,0x88,0x78,0x78,0x69,0x78,0x87,//1999
0x96,0xB4,0xA5,0xB5,0xA6,0xA6,0x87,0x88,0x88,0x78,0x87,0x86,//2000
0xA5,0xB3,0xA5,0xA5,0xA6,0xA6,0x88,0x88,0x88,0x78,0x87,0x87,//2001
0xA5,0xB4,0x96,0xA5,0x96,0x96,0x88,0x78,0x78,0x78,0x87,0x87,//2002
0x95,0xB4,0x96,0xA5,0x96,0x97,0x88,0x78,0x78,0x69,0x78,0x87,//2003
0x96,0xB4,0xA5,0xB5,0xA6,0xA6,0x87,0x88,0x88,0x78,0x87,0x86,//2004
0xA5,0xB3,0xA5,0xA5,0xA6,0xA6,0x88,0x88,0x88,0x78,0x87,0x87,//2005
0xA5,0xB4,0x96,0xA5,0xA6,0x96,0x88,0x88,0x78,0x78,0x87,0x87,//2006
0x95,0xB4,0x96,0xA5,0x96,0x97,0x88,0x78,0x78,0x69,0x78,0x87,//2007
0x96,0xB4,0xA5,0xB5,0xA6,0xA6,0x87,0x88,0x87,0x78,0x87,0x86,//2008
0xA5,0xB3,0xA5,0xB5,0xA6,0xA6,0x88,0x88,0x88,0x78,0x87,0x87,//2009
0xA5,0xB4,0x96,0xA5,0xA6,0x96,0x88,0x88,0x78,0x78,0x87,0x87,//2010
0x95,0xB4,0x96,0xA5,0x96,0x97,0x88,0x78,0x78,0x79,0x78,0x87,//2011
0x96,0xB4,0xA5,0xB5,0xA5,0xA6,0x87,0x88,0x87,0x78,0x87,0x86,//2012
0xA5,0xB3,0xA5,0xB5,0xA6,0xA6,0x87,0x88,0x88,0x78,0x87,0x87,//2013
0xA5,0xB4,0x96,0xA5,0xA6,0x96,0x88,0x88,0x78,0x78,0x87,0x87,//2014
0x95,0xB4,0x96,0xA5,0x96,0x97,0x88,0x78,0x78,0x79,0x77,0x87,//2015
0x95,0xB4,0xA5,0xB4,0xA5,0xA6,0x87,0x88,0x87,0x78,0x87,0x86,//2016
0xA5,0xC3,0xA5,0xB5,0xA6,0xA6,0x87,0x88,0x88,0x78,0x87,0x87,//2017
0xA5,0xB4,0xA6,0xA5,0xA6,0x96,0x88,0x88,0x78,0x78,0x87,0x87,//2018
0xA5,0xB4,0x96,0xA5,0x96,0x96,0x88,0x78,0x78,0x79,0x77,0x87,//2019
0x95,0xB4,0xA5,0xB4,0xA5,0xA6,0x97,0x87,0x87,0x78,0x87,0x86,//2020
0xA5,0xC3,0xA5,0xB5,0xA6,0xA6,0x87,0x88,0x88,0x78,0x87,0x86,//2021
0xA5,0xB4,0xA5,0xA5,0xA6,0x96,0x88,0x88,0x88,0x78,0x87,0x87,//2022
0xA5,0xB4,0x96,0xA5,0x96,0x96,0x88,0x78,0x78,0x79,0x77,0x87,//2023
0x95,0xB4,0xA5,0xB4,0xA5,0xA6,0x97,0x87,0x87,0x78,0x87,0x96,//2024
0xA5,0xC3,0xA5,0xB5,0xA6,0xA6,0x87,0x88,0x88,0x78,0x87,0x86,//2025
0xA5,0xB3,0xA5,0xA5,0xA6,0xA6,0x88,0x88,0x88,0x78,0x87,0x87,//2026
0xA5,0xB4,0x96,0xA5,0x96,0x96,0x88,0x78,0x78,0x78,0x87,0x87,//2027
0x95,0xB4,0xA5,0xB4,0xA5,0xA6,0x97,0x87,0x87,0x78,0x87,0x96,//2028
0xA5,0xC3,0xA5,0xB5,0xA6,0xA6,0x87,0x88,0x88,0x78,0x87,0x86,//2029
0xA5,0xB3,0xA5,0xA5,0xA6,0xA6,0x88,0x88,0x88,0x78,0x87,0x87,//2030
0xA5,0xB4,0x96,0xA5,0x96,0x96,0x88,0x78,0x78,0x78,0x87,0x87,//2031
0x95,0xB4,0xA5,0xB4,0xA5,0xA6,0x97,0x87,0x87,0x78,0x87,0x96,//2032
0xA5,0xC3,0xA5,0xB5,0xA6,0xA6,0x88,0x88,0x88,0x78,0x87,0x86,//2033
0xA5,0xB3,0xA5,0xA5,0xA6,0xA6,0x88,0x78,0x88,0x78,0x87,0x87,//2034
0xA5,0xB4,0x96,0xA5,0xA6,0x96,0x88,0x88,0x78,0x78,0x87,0x87,//2035
0x95,0xB4,0xA5,0xB4,0xA5,0xA6,0x97,0x87,0x87,0x78,0x87,0x96,//2036
0xA5,0xC3,0xA5,0xB5,0xA6,0xA6,0x87,0x88,0x88,0x78,0x87,0x86,//2037
0xA5,0xB3,0xA5,0xA5,0xA6,0xA6,0x88,0x88,0x88,0x78,0x87,0x87,//2038
0xA5,0xB4,0x96,0xA5,0xA6,0x96,0x88,0x88,0x78,0x78,0x87,0x87,//2039
0x95,0xB4,0xA5,0xB4,0xA5,0xA6,0x97,0x87,0x87,0x78,0x87,0x96,//2040
0xA5,0xC3,0xA5,0xB5,0xA5,0xA6,0x87,0x88,0x87,0x78,0x87,0x86,//2041
0xA5,0xB3,0xA5,0xB5,0xA6,0xA6,0x88,0x88,0x88,0x78,0x87,0x87,//2042
0xA5,0xB4,0x96,0xA5,0xA6,0x96,0x88,0x88,0x78,0x78,0x87,0x87,//2043
0x95,0xB4,0xA5,0xB4,0xA5,0xA6,0x97,0x87,0x87,0x88,0x87,0x96,//2044
0xA5,0xC3,0xA5,0xB4,0xA5,0xA6,0x87,0x88,0x87,0x78,0x87,0x86,//2045
0xA5,0xB3,0xA5,0xB5,0xA6,0xA6,0x87,0x88,0x88,0x78,0x87,0x87,//2046
0xA5,0xB4,0x96,0xA5,0xA6,0x96,0x88,0x88,0x78,0x78,0x87,0x87,//2047
0x95,0xB4,0xA5,0xB4,0xA5,0xA5,0x97,0x87,0x87,0x88,0x86,0x96,//2048
0xA4,0xC3,0xA5,0xA5,0xA5,0xA6,0x97,0x87,0x87,0x78,0x87,0x86,//2049
0xA5,0xC3,0xA5,0xB5,0xA6,0xA6,0x87,0x88,0x78,0x78,0x87,0x87};//2050
privateDateTimem_Date;
publicDateTimeDate
{
get{returnm_Date;}
set{m_Date=value;}
}
publicCNDate()
{
Date=DateTime.Today;
}
publicCNDate(DateTimedt)
{
Date=dt.Date;
}
//计算指定日期的星座序号
publicintGetConstellation()
{
intY,M,D;
Y=m_Date.Year;
M=m_Date.Month;
D=m_Date.Day;
Y=M*100+D;
if(((Y>=321)&&(Y<=419))){return0;}
elseif((Y>=420)&&(Y<=520)){return1;}
elseif((Y>=521)&&(Y<=620)){return2;}
elseif((Y>=621)&&(Y<=722)){return3;}
elseif((Y>=723)&&(Y<=822)){return4;}
elseif((Y>=823)&&(Y<=922)){return5;}
elseif((Y>=923)&&(Y<=1022)){return6;}
elseif((Y>=1023)&&(Y<=1121)){return7;}
elseif((Y>=1122)&&(Y<=1221)){return8;}
elseif((Y>=1222)||(Y<=119)){return9;}
elseif((Y>=120)&&(Y<=218)){return10;}
elseif((Y>=219)&&(Y<=320)){return11;}
else{return-1;};
}
//计算指定日期的星座名称
publicstringGetConstellationName()
{
intConstellation;
Constellation=GetConstellation();
if((Constellation>=0)&&(Constellation<=11))
{returnConstellationName[Constellation];}
else
{return"";};
}
//计算公历当天对应的节气0-23,-1表示不是节气
publicintl_GetLunarHolDay()
{
byteFlag;
intDay,iYear,iMonth,iDay;
iYear=m_Date.Year;
if((iYear<START_YEAR)||(iYear>END_YEAR))
{return-1;};
iMonth=m_Date.Month;
iDay=m_Date.Day;
Flag=gLunarHolDay[(iYear-START_YEAR)*12+iMonth-1];
if(iDay<15)
{Day=15-((Flag>>4)&0x0f);}
else
{Day=(Flag&0x0f)+15;};
if(iDay==Day)
{
if(iDay>15)
{return(iMonth-1)*2+1;}
else
{return(iMonth-1)*2;}
}
else
{return-1;};
}
publicstringFormatMonth(ushortiMonth,boolbLunar)
{
stringszText="正二三四五六七八九十";
stringstrMonth;
if((!bLunar)&&(iMonth==1))
{return"一月";}
if(iMonth<=10)
{
strMonth="";
strMonth=strMonth+szText.Substring(iMonth-1,1);
strMonth=strMonth+"月";
returnstrMonth;
}
if(iMonth==11)
{strMonth="十一";}
else
{strMonth="十二";}
returnstrMonth+"月";
}
publicstringFormatLunarDay(ushortiDay)
{
stringszText1="初十廿三";
stringszText2="一二三四五六七八九十";
stringstrDay;
if((iDay!=20)&&(iDay!=30))
{
strDay=szText1.Substring((iDay-1)/10,1);
strDay=strDay+szText2.Substring((iDay-1)%10,1);
}
else
{
strDay=szText1.Substring((iDay/10)*2+1,2);
strDay=strDay+"十";
}
returnstrDay;
}
publicstringGetLunarHolDay()
{
ushortiYear,iMonth,iDay;
inti;
TimeSpants;
iYear=(ushort)(m_Date.Year);
if((iYear<START_YEAR)||(iYear>END_YEAR))
{return"";};
i=l_GetLunarHolDay();
if((i>=0)&&(i<=23))
{returnLunarHolDayName[i];}
else
{
ts=m_Date-(newDateTime(START_YEAR,1,1));
l_CalcLunarDate(outiYear,outiMonth,outiDay,(uint)(ts.Days));
returnFormatMonth(iMonth,true)+FormatLunarDay(iDay);
}
}
//返回阴历iLunarYear年的闰月月份,如没有返回01901年1月---2050年12月
publicintGetLeapMonth(ushortiLunarYear)
{
byteFlag;
if((iLunarYear<START_YEAR)||(iLunarYear>END_YEAR))
{return0;};
Flag=gLunarMonth[(iLunarYear-START_YEAR)/2];
if((iLunarYear-START_YEAR)%2==0)
{returnFlag>>4;}
else
{returnFlag&0x0F;}
}
//返回阴历iLunarYer年阴历iLunarMonth月的天数,如果iLunarMonth为闰月,
//高字为第二个iLunarMonth月的天数,否则高字为01901年1月---2050年12月
publicuintLunarMonthDays(ushortiLunarYear,ushortiLunarMonth)
{
intHeight,Low;
intiBit;
if((iLunarYear<START_YEAR)||(iLunarYear>END_YEAR))
{return30;}
Height=0;
Low=29;
iBit=16-iLunarMonth;
if((iLunarMonth>GetLeapMonth(iLunarYear))&&(GetLeapMonth(iLunarYear)>0))
{iBit--;}
if((gLunarMonthDay[iLunarYear-START_YEAR]&(1<<iBit))>0)
{Low++;}
if(iLunarMonth==GetLeapMonth(iLunarYear))
{
if((gLunarMonthDay[iLunarYear-START_YEAR]&(1<<(iBit-1)))>0)
{Height=30;}
else
{Height=29;}
}
return(uint)((uint)(Low)|(uint)(Height)<<16);//合成为uint
}
//返回阴历iLunarYear年的总天数1901年1月---2050年12月
publicintLunarYearDays(ushortiLunarYear)
{
intDays;
uinttmp;
if((iLunarYear<START_YEAR)||(iLunarYear>END_YEAR))
{return0;};
Days=0;
for(ushorti=1;i<=12;i++)
{
tmp=LunarMonthDays(iLunarYear,i);
Days=Days+((ushort)(tmp>>16)&0xFFFF);//取高位
Days=Days+(ushort)(tmp);//取低位
}
returnDays;
}
//计算从1901年1月1日过iSpanDays天后的阴历日期
publicvoidl_CalcLunarDate(outushortiYear,outushortiMonth,outushortiDay,uintiSpanDays)
{
uinttmp;
//阳历1901年2月19日为阴历1901年正月初一
//阳历1901年1月1日到2月19日共有49天
if(iSpanDays<49)
{
iYear=START_YEAR-1;
if(iSpanDays<19)
{
iMonth=11;
iDay=(ushort)(11+iSpanDays);
}
else
{
iMonth=12;
iDay=(ushort)(iSpanDays-18);
}
return;
}
//下面从阴历1901年正月初一算起
iSpanDays=iSpanDays-49;
iYear=START_YEAR;
iMonth=1;
iDay=1;
//计算年
tmp=(uint)LunarYearDays(iYear);
while(iSpanDays>=tmp)
{
iSpanDays=iSpanDays-tmp;
iYear++;
tmp=(uint)LunarYearDays(iYear);
}
//计算月
tmp=LunarMonthDays(iYear,iMonth);//取低位
while(iSpanDays>=tmp)
{
iSpanDays=iSpanDays-tmp;
if(iMonth==GetLeapMonth(iYear))
{
tmp=(LunarMonthDays(iYear,iMonth)>>16)&0xFFFF;//取高位
if(iSpanDays<tmp)
{break;}
iSpanDays=iSpanDays-tmp;
}
iMonth++;
tmp=LunarMonthDays(iYear,iMonth);//取低位
}
//计算日
iDay=(ushort)(iDay+iSpanDays);
}
//把iYear年格式化成天干记年法表示的字符串
publicstringFormatLunarYear()
{
stringstrYear;
stringszText1="甲乙丙丁戊己庚辛壬癸";
stringszText2="子丑寅卯辰巳午未申酉戌亥";
stringszText3="鼠牛虎免龙蛇马羊猴鸡狗猪";
ushortiYear;
iYear=(ushort)(m_Date.Year);
strYear=szText1.Substring((iYear-4)%10,1);
strYear=strYear+szText2.Substring((iYear-4)%12,1);
strYear=strYear+"";
strYear=strYear+szText3.Substring((iYear-4)%12,1);
strYear=strYear+"年";
returnstrYear;
}
}//classCNDate
publicclassTest
{
staticvoidMain(string[]args)
{
CNDatedt=newCNDate(DateTime.Today);
Console.WriteLine("今天是:"+dt.Date.ToString()+dt.GetConstellationName());
Console.WriteLine(dt.l_GetLunarHolDay());
Console.WriteLine(dt.GetLunarHolDay());
Console.WriteLine("闰月"+dt.GetLeapMonth(UInt16.Parse(args[0])));
Console.WriteLine("2月的天数"+dt.LunarMonthDays(UInt16.Parse(args[0]),UInt16.Parse(args[1])));
Console.WriteLine("天数"+dt.LunarYearDays(UInt16.Parse(args[0])));
Console.WriteLine(""+dt.FormatLunarYear());
dt.Date=DateTime.Today.AddDays(1);
Console.WriteLine("明天是:"+dt.Date.ToString()+dt.GetConstellationName());
}
}//classTest
}
相关推荐
农历,也称为阴历,是中国和其他东亚国家传统使用的历法,而公历则是国际上广泛采用的格里高利历。本文将详细介绍如何在C#中实现农历与公历之间的转换,特别关注1902年至2100年这段时期。 首先,我们需要理解农历和...
"C#农历源代码"是一个用于计算阴历日期及其相关属性如天干地支的程序模块,特别适用于那些需要在应用中集成农历功能的开发者。 农历,又称阴历,是根据月亮的运行周期来确定日期的历法。在中国传统农历中,一年分为...
c# 农历代码(包含使用范例) 这里凑几个字上传
根据提供的信息,我们可以总结出以下关于C#中的农历和节气相关的知识点: ### C# 农历和节气概述 1. **农历日期转换:** 通过提供的代码片段可以看出,这是一个用于将公历日期转换为农历日期的工具类 `...
- 使用`ChineseLunisolarCalendar`类来处理阳历与阴历之间的转换,该类位于`System.Globalization`命名空间中,专门用于处理中国的阴历(农历)纪年法。 3. **核心逻辑**: - 定义数据库连接字符串(`strlike`)...
之前曾经上传过一个农历处理类,但遇到润年月会出异常.这个是对网上的改进版,经测试正常,我的项目中都在使用.在这里共享出来..... 文件里有使用说明.使用时调用两个静态函数即可: /// /// 显示: 农历 闰五月十一...
分享给有需要的朋友!!
在.NET开发环境中,C#是一种常用的编程语言,而“c#农历链接库,附源码”则提供了一种方便开发者处理农历日期的工具。这个动态链接库(Lunar.dll)是一个专门为C#设计的农历计算模块,允许程序员轻松地在应用程序中...
农历,又称阴历,是以月亮的盈亏周期为依据的日历系统。一个月通常包括29天或30天,一年则由12个月组成,但为了保持与太阳年同步,农历年会插入闰月。因此,农历年的长度通常在354到355天之间,与公历(阳历)的365...
根据给定的信息,本文将详细解析“C#农历算法”这一主题所涉及的关键知识点,包括农历与公历的转换逻辑、星座查询、天干地支以及生肖计算等内容。 ### C#农历算法概述 该程序主要通过一个名为`DateConvert`的类...
在C#编程环境中,开发一个能够显示日期,尤其是包括农历日期的应用程序,是常见的需求。这个项目显然关注的是创建一个简单界面,虽然它可能在视觉设计上并不出色,但核心功能在于有效地展示公历和农历日期。让我们...
### C#农历程序:深入解析与应用 #### 核心知识点概述 在现代软件开发领域,尤其是对于中国传统文化的应用场景,农历(阴历)日期的处理成为了一个不可忽视的需求。本篇文章将围绕“C#农历程序”这一主题展开,...
本主题主要围绕C#如何实现农历转换和显示的功能,这对于开发需要涉及农历计算的软件,如日历应用、节假日提醒等,具有重要的实践价值。 首先,我们需要理解农历和阳历的区别。阳历,即公历,是国际通用的日历系统,...
该工具支持阴历日期的多种格式,包括干支纪年、农历日期和阳历日期等。 4. 日期转换示例: 例如,阳历2007年2月9日对应的阴历日期是二〇〇六年十二月廿二日,属丙戌年(狗年)。使用该工具可以轻松地将阳历日期...
本项目涉及的核心知识点是C#语言和WinForm框架下实现阴历与阳历之间的转换,这在很多文化传统应用中非常实用,比如在中国,农历(阴历)与公历(阳历)的转换经常被用于节日和纪念日的计算。下面我们将详细讨论相关...
在本文中,我们将深入探讨如何使用C# Winform开发一个美观且功能丰富的万年历应用程序,包括农历显示和节日功能。C#是一种广泛应用于Windows桌面应用开发的强大编程语言,Winform则是C#中的一个框架,用于创建图形...
这个是把C代码迁移到了C#上了。我用了一天时间迁移这个库成为一额个C#的静态类库。对于一个首次接触C#的C程序鱼来说多么的不容易啊…… 尽可能还是按照C风格的用法来迁移成的这个类库。附有测试用例,可以看到用法。...
在C#编程中,开发一个阴历转阳历的类是一...通过理解农历和阳历之间的关系,以及C#编程基础,我们可以构建出一个功能完备且准确的阴历转阳历类。在实现转换算法时,可以参考历史数据或现有的农历库,确保转换的准确性。
对于“C#阴阳历转换”这个小程序,它的核心功能就是将公历(阳历)日期转换为农历(阴历),反之亦然。这样的工具在日历应用、中国传统节日提醒、星座运势查询等领域非常有用。 首先,我们需要了解阴阳历的基本概念...
在这个特定的场景中,我们讨论的是一个用C#编写的类,这个类专门处理农历日期和相关的计算。在许多亚洲国家和地区,如中国、台湾、香港、新加坡等地,农历在日常生活和节日庆祝中扮演着重要角色。因此,能够处理农历...