using System;
using System.Collections;
using System.Text;
using System.Globalization;
namespace 农历
{
public class ChineseCalendar
{
#region 农历使用的各类型数组
/// <summary>
/// 天干数组
/// </summary>
private string[] m_SkyNum ={ "空", "甲", "乙", "丙", "丁", "戊", "己", "庚", "辛", "壬", "癸" };
/// <summary>
/// 天干五行数组
/// </summary>
private string[] m_SkyActionNum ={"空","阳木","阴木","阳火","阴火","阳土","阴土","阳金","阴金","阳水","阴水"};
/// <summary>
/// 地支数组
/// </summary>
private string[] m_EarthNum ={ "空", "子", "丑", "寅", "卯", "辰", "巳", "午", "未", "申", "酉", "戌", "亥" };
/// <summary>
/// 地支五行数组
/// </summary>
private string[] m_EarthActionNum ={ "空", "阳水","阴土","阳木","阴木","阳土","阴火","阳火","阴土","阳金","阴金","阳土","阴水" };
/// <summary>
/// 属相数组
/// </summary>
private string[] m_AttrNum ={ "空", "鼠", "牛", "虎", "兔", "龙", "蛇", "马", "羊", "猴", "鸡", "狗", "猪" };
/// <summary>
/// 农历日期数组
/// </summary>
private string[] m_ChineseDayNum ={"空","初一","初二","初三","初四","初五","初六","初七","初八","初九","初十","十一","十二","十三","十四",
"十五","十六","十七","十八","十九","二十","二十一","二十二","二十三","二十四","二十五","二十六","二十七","二十八","二十九","三十"};
// private string[] m_JieQiNum={"小寒","大寒","立春","雨水","惊蛰","春分","清明","谷雨","立夏","小满","芒种","夏至","小暑","大暑","立秋","处暑","白露","秋分","寒露","霜降","立冬","小雪","大雪","冬至"};
// private int[] sTermInfo = {0,21208,42467,63836,85337,107014,128867,150921,173149,195551,218072,240693,263343,285989,308563,331033,353350,375494,397447,419210,440795,462224,483532,504758};
/// <summary>
///农历月份数组
/// </summary>
private string[] m_ChineseMonthNum ={ "空", "正月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月(腊月)" };
/// <summary>
/// 农历甲子循环数组
/// </summary>
private string[] m_SkyEarthNum = new string[61];
/// <summary>
/// 天干数组属性
/// </summary>
public string[] SkyNum
{
get
{
return m_SkyNum;
}
}
/// <summary>
/// 地支数组属性
/// </summary>
public string[] EarthNum
{
get
{
return m_EarthNum;
}
}
/// <summary>
/// 属相数组属性
/// </summary>
public string[] AttrNum
{
get
{
return m_AttrNum;
}
}
#endregion
#region 成员属性
/// <summary>
/// 天干地支
/// </summary>
private string m_SkyEarth = "";
/// <summary>
/// 天干地支
/// </summary>
public string SkyEarth
{
get
{
return m_SkyEarth;
}
}
/// <summary>
/// 天干地支五行
/// </summary>
private string m_FiveAction = "";
/// <summary>
/// 天干地支五行
/// </summary>
public string FiveAction
{
get
{
return m_FiveAction;
}
}
/// <summary>
/// 天干
/// </summary>
private string m_Sky = "";
/// <summary>
/// 天干
/// </summary>
public string Sky
{
get
{
return m_Sky;
}
}
/// <summary>
/// 天干五行
/// </summary>
private string m_SkyAction = "";
/// <summary>
/// 天干五行
/// </summary>
public string SkyAction
{
get
{
return m_SkyAction;
}
}
/// <summary>
/// 地支
/// </summary>
private string m_Earth = "";
/// <summary>
/// 地支
/// </summary>
public string Earth
{
get
{
return m_Earth;
}
}
/// <summary>
/// 地支五行
/// </summary>
private string m_EarthAction = "";
/// <summary>
/// 地支五行
/// </summary>
public string EarthAction
{
get
{
return m_EarthAction;
}
}
/// <summary>
/// 农历年份[年柱]
/// </summary>
private string m_Year = "";
/// <summary>
/// 农历年份[年柱]
/// </summary>
public string Year
{
get
{
return m_Year;
}
}
/// <summary>
/// 农历月份
/// </summary>
private string m_Month = "";
/// <summary>
/// 农历月份
/// </summary>
public string Month
{
get
{
return m_Month;
}
}
/// <summary>
/// 农历日期
/// </summary>
private string m_Day = "";
/// <summary>
/// 农历日期
/// </summary>
public string Day
{
get
{
return m_Day;
}
}
/// <summary>
/// 农历时辰
/// </summary>
private string m_Hour = "";
/// <summary>
/// 农历时辰
/// </summary>
public string Hour
{
get
{
return m_Hour;
}
}
/// <summary>
/// 年柱
/// </summary>
private ChineseEra m_yearPillar;
/// <summary>
/// 年柱
/// </summary>
public ChineseEra YearPillar
{
get
{
return m_yearPillar;
}
}
/// <summary>
/// 月柱
/// </summary>
private ChineseEra m_monthPillar;
/// <summary>
/// 月柱
/// </summary>
public ChineseEra MonthPillar
{
get
{
return m_monthPillar;
}
}
/// <summary>
/// 日柱
/// </summary>
private ChineseEra m_dayPillar;
/// <summary>
/// 日柱
/// </summary>
public ChineseEra DayPillar
{
get
{
return m_dayPillar;
}
}
/// <summary>
/// 时柱
/// </summary>
private ChineseEra m_hourPillar;
/// <summary>
/// 时柱
/// </summary>
public ChineseEra HourPillar
{
get
{
return m_hourPillar;
}
}
#endregion
/// <summary>
/// 构造函数
/// </summary>
public ChineseCalendar(DateTime dt)
{
this.LoadChineseDate();
this.GetChineseCalendar(dt);
//ChineseEra m=(ChineseEra)8;
//System.Diagnostics.Debug.WriteLine(m.ToString());
}
#region 填充60甲子年
/// <summary>
/// 填充60甲子年
/// </summary>
private void LoadChineseDate()
{
m_SkyEarthNum[0] = "空";
for (int i = 1; i <= 60; i++)
{
int m = i % 10;
if (m == 0)
m = 10;
int n = i % 12;
if (n == 0)
n = 12;
m_SkyEarthNum[i] = m_SkyNum[m].ToString() + m_EarthNum[n].ToString();
}
}
#endregion
#region 依据公历获得对应的农历
/// <summary>
/// 依据公历获得对应的农历
/// </summary>
/// <param name="dt">选择的日期</param>
public void GetChineseCalendar(DateTime dt)
{
ChineseLunisolarCalendar calendar = new ChineseLunisolarCalendar();
//获得指定年份的天干地支--方法一
// m_SkyEarth = "" + m_SkyEarthNum[this.GetChineseEraOfYear(dt)];
//方法二
m_SkyEarth = ((ChineseEra)this.GetChineseEraOfYear(dt)).ToString();
//天干
m_Sky = "" + m_SkyNum[calendar.GetCelestialStem(this.GetChineseEraOfYear(dt))];
//天干五行
m_SkyAction = "" + m_SkyActionNum[calendar.GetCelestialStem(this.GetChineseEraOfYear(dt))];
//地支(属相)
m_Earth = "" + m_EarthNum[calendar.GetTerrestrialBranch(this.GetChineseEraOfYear(dt))] + "(" + m_AttrNum[calendar.GetTerrestrialBranch(this.GetChineseEraOfYear(dt))] + ")";
//地支五行
m_EarthAction = "" + m_EarthActionNum[calendar.GetTerrestrialBranch(this.GetChineseEraOfYear(dt))];
//天干地支五行
m_FiveAction = this.GetFiveAction(m_SkyEarth);
//农历年份
m_Year = m_SkyEarth + "年";
#region 判断闰年闰月
//判断是否是闰月
if (calendar.GetMonthsInYear(dt.Year) == 13)
{
int a = 0;
for (int i = 1; i <= 12; i++)
{
if (calendar.IsLeapMonth(dt.Year, i))
{
a = i;
}
}
if (dt.Month > a)
m_Month = m_ChineseMonthNum[calendar.GetMonth(dt) - 1];
else
m_Month = m_ChineseMonthNum[calendar.GetMonth(dt)];
}
else if (calendar.GetMonthsInYear(dt.Year - 1) == 13 && calendar.GetMonth(dt) >= 12)
{
m_Month = m_ChineseMonthNum[calendar.GetMonth(dt) - 1];
}
else
{
m_Month = m_ChineseMonthNum[calendar.GetMonth(dt)];
}
#endregion
//农历日期
m_Day = m_ChineseDayNum[calendar.GetDayOfMonth(dt)] ;
//农历时辰
m_Hour = this.GetShiCheng(dt) ;
}
#endregion
#region 依据天干地支获得五行所属
/// <summary>
/// 依据天干地支获得五行所属
/// </summary>
/// <param name="skyEarth"></param>
/// <returns></returns>
public string GetFiveAction(string skyEarth)
{
/*
甲子乙丑海中金,丙寅丁卯炉中火,戊辰己巳大林木,庚午辛未路旁土,
壬申辛酉剑锋金,甲戌乙亥山头火,丙子丁丑涧下水,戊寅己卯城头土,
庚辰辛巳白腊金,壬午癸未杨柳木,甲申乙酉泉中水,丙戌丁亥屋上土,
戊子己丑霹雳火,庚寅辛卯松柏木,任辰癸巳长流水,甲午乙未沙中金,
丙申丁酉山下火,戊戌己亥平地木,庚子辛丑壁上土,壬寅癸卯金箔金,
甲辰乙己复灯火,丙午丁未天河水,戊申己本大驿土,庚戌辛亥钗钏金,
壬子癸丑桑柘木,甲寅乙卯大溪水,丙辰丁巳水各土,戊午己未天上火,
庚申辛酉石榴木,壬戌癸亥大海水。
*/
string result = "";
switch (skyEarth)
{
case "甲子":
case "乙丑":
result = "海中金";
break;
case "丙寅":
case "丁卯":
result = "炉中火";
break;
case "戊辰":
case "己巳":
result = "大林木";
break;
case "庚午":
case "辛未":
result = "路旁土"; // 甲子乙丑海中金,丙寅丁卯炉中火,戊辰己巳大林木,庚午辛未路旁土,
break;
case "壬申":
case "癸酉":
result = "剑锋金";
break;
case "甲戌":
case "乙亥":
result = "山头火";
break;
case "丙子":
case "丁丑":
result = "涧下水";
break;
case "戊寅":
case "己卯":
result = "城头土"; //壬申辛酉剑锋金,甲戌乙亥山头火,丙子丁丑涧下水,戊寅己卯城头土,
break;
case "庚辰":
case "辛巳":
result = "白腊金";
break;
case "壬午":
case "癸未":
result = "杨柳木";
break;
case "甲申":
case "乙酉":
result = "泉中水";
break;
case "丙戌":
case "丁亥":
result = "屋上土"; // 庚辰辛巳白腊金,壬午癸未杨柳木,甲申乙酉泉中水,丙戌丁亥屋上土,
break;
case "戊子":
case "己丑":
result = "霹雳火";
break;
case "庚寅":
case "辛卯":
result = "松柏木";
break;
case "任辰":
case "癸巳":
result = "长流水";
break;
case "甲午":
case "乙未":
result = "沙中金";// 戊子己丑霹雳火,庚寅辛卯松柏木,任辰癸巳长流水,甲午乙未沙中金,
break;
case "丙申":
case "丁酉":
result = "山下火";
break;
case "戊戌":
case "己亥":
result = "平地木";
break;
case "庚子":
case "辛丑":
result = "壁上土";
break;
case "壬寅":
case "癸卯":
result = "金箔金";// 丙申丁酉山下火,戊戌己亥平地木,庚子辛丑壁上土,壬寅癸卯金箔金,
break;
case "甲辰":
case "乙己":
result = "佛灯火";
break;
case "丙午":
case "丁未":
result = "天河水";
break;
case "戊申":
case "己酉":
result = "大驿土";
break;
case "庚戌":
case "辛亥":
result = "钗钏金";// 甲辰乙己复灯火,丙午丁未天河水,戊申己酉大驿土,庚戌辛亥钗钏金,
break;
case "壬子":
case "癸丑":
result = "桑柘木";
break;
case "甲寅":
case "乙卯":
result = "大溪水";
break;
case "丙辰":
case "丁巳":
result = "沙中土";
break;
case "戊午":
case "己未":
result = "天上火";// 壬子癸丑桑柘木,甲寅乙卯大溪水,丙辰丁巳水各土,戊午己未天上火,
break;
case "庚申":
case "辛酉":
result = "石榴木";
break;
case "壬戌":
case "癸亥":
result = "大海水";// 庚申辛西石榴木,壬戌癸亥大海水。
break;
}
return result;
}//method string GetFiveAction(...);
#endregion
#region 依据时间获得农历时辰
/// <summary>
/// 依据时间获得农历时辰
/// </summary>
/// <param name="dt"></param>
/// <returns></returns>
public string GetShiCheng(DateTime dt)
{
string shiCheng="";
switch (dt.Hour)
{
case 23:
case 0:
shiCheng = "子时";
break;
case 1:
case 2:
shiCheng = "丑时";
break;
case 3:
case 4:
shiCheng ="寅时";
break;
case 5:
case 6:
shiCheng ="卯时";
break;
case 7:
case 8:
shiCheng ="辰时";
break;
case 9:
case 10:
shiCheng ="巳时";
break;
case 11:
case 12:
shiCheng ="午时";
break;
case 13:
case 14:
shiCheng ="未时";
break;
case 15:
case 16:
shiCheng ="申时";
break;
case 17:
case 18:
shiCheng ="酉时";
break;
case 19:
case 20:
shiCheng ="戌时";
break;
case 21:
case 22:
shiCheng ="亥时";
break;
}
return shiCheng;
}
#endregion
#region 推算年柱月柱日柱时柱(八字)
/// <summary>
/// 获取年柱。
/// </summary>
public int GetChineseEraOfYear(DateTime solarDateTime)
{
int g = (solarDateTime.Year - 1900 + 36) % 60;
if ((DayDifference(solarDateTime.Year, solarDateTime.Month, solarDateTime.Day) + solarDateTime.Hour / 24) < Term(solarDateTime.Year, 3, true) - 1)
{//判断是否过立春
g -= 1;
}
return g + 1;
}
/// <summary>
/// 获取月柱。
/// </summary>
public int GetChineseEraOfMonth(DateTime solarDateTime)
{
int v = ((solarDateTime.Year - 1900) * 12 + solarDateTime.Month + 12) % 60;
if (solarDateTime.Day <= GetSolarTerm(solarDateTime)[0].SolarTermDateTime.Day)
v -= 1;
return v + 1;
}
/// <summary>
/// 获取日柱。
/// </summary>
public int GetChineseEraOfDay(DateTime solarDateTime)
{
double gzD = (solarDateTime.Hour < 23) ? EquivalentStandardDay(solarDateTime.Year, solarDateTime.Month, solarDateTime.Day) : EquivalentStandardDay(solarDateTime.Year, solarDateTime.Month, solarDateTime.Day) + 1;
return (int)Math.Round((double)rem((int)gzD + 15, 60));
}
/// <summary>
/// 获取时柱。
/// </summary>
public int GetChineseEraOfHour(DateTime solarDateTime)
{
double v = 12 * Gan(GetChineseEraOfDay(solarDateTime)) + System.Math.Floor((double)((solarDateTime.Hour + 1) / 2)) - 11;
if (solarDateTime.Hour == 23)
v -= 12;
return (int)Math.Round(rem(v, 60));
}
/// <summary>
/// 推算年柱月柱日柱时柱(八字)
/// </summary>
/// <param name="dt"></param>
public void GetEightCharacterAboutOneBirth(DateTime dt)
{
this.m_yearPillar = (ChineseEra)this.GetChineseEraOfYear(dt);
this.m_monthPillar = (ChineseEra)this.GetChineseEraOfMonth(dt);
this.m_dayPillar = (ChineseEra)this.GetChineseEraOfDay(dt);
this.m_hourPillar = (ChineseEra)this.GetChineseEraOfHour(dt);
}//method GetEightCharacterAboutOneBirth(...);
#endregion
#region 获取二十四节气的日期
/// <summary>
/// 判断y年m月(1,2,..,12,下同)d日是Gregorian历还是Julian历(opt=1,2,3分别表示标准日历,Gregorge历和Julian历),是则返回1,是Julian历则返回0,若是Gregorge历所删去的那10天则返回-1
/// </summary>
private int IfGregorian(int y, int m, int d, int opt)
{
if (opt == 1)
{
if (y > 1582 || (y == 1582 && m > 10) || (y == 1582 && m == 10 && d > 14))
return (1); //Gregorian
else
if (y == 1582 && m == 10 && d >= 5 && d <= 14)
return (-1); //空
else
return (0); //Julian
}
if (opt == 2)
return (1); //Gregorian
if (opt == 3)
return (0); //Julian
return (-1);
}
/// <summary>
/// 返回等效标准天数(y年m月d日相应历种的1年1月1日的等效(即对Gregorian历与Julian历是统一的)天数)
/// </summary>
private double EquivalentStandardDay(int y, int m, int d)
{
double v = (y - 1) * 365 + Math.Floor((double)((y - 1) / 4)) + DayDifference(y, m, d) - 2; //Julian的等效标准天数
if (y > 1582)
v += -Math.Floor((double)((y - 1) / 100)) + Math.Floor((double)((y - 1) / 400)) + 2; //Gregorian的等效标准天数
return v;
}
/// <summary>
/// 返回阳历y年m月d日的日差天数(在y年年内所走过的天数,如2000年3月1日为61)
/// </summary>
private int DayDifference(int y, int m, int d)
{
int ifG = IfGregorian(y, m, d, 1);
int[] monL = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
if (ifG == 1)
if ((y % 100 != 0 && y % 4 == 0) || (y % 400 == 0))
monL[2] += 1;
else
if (y % 4 == 0)
monL[2] += 1;
int v = 0;
for (int i = 0; i <= m - 1; i++)
{
v += monL[i];
}
v += d;
if (y == 1582)
{
if (ifG == 1)
v -= 10;
if (ifG == -1)
v = 0; //infinity
}
return v;
}
//原始:S
/// <summary>
///返回y年第n个节气(如小寒为1)的日差天数值(pd取值真假,分别表示平气和定气)
/// </summary>
private double Term(int y, int n, bool pd)
{
double juD = y * (365.2423112 - 6.4e-14 * (y - 100) * (y - 100) - 3.047e-8 * (y - 100)) + 15.218427 * n + 1721050.71301;//儒略日
double tht = 3e-4 * y - 0.372781384 - 0.2617913325 * n;//角度
double yrD = (1.945 * Math.Sin(tht) - 0.01206 * Math.Sin(2 * tht)) * (1.048994 - 2.583e-5 * y);//年差实均数
double shuoD = -18e-4 * Math.Sin(2.313908653 * y - 0.439822951 - 3.0443 * n);//朔差实均数
double vs = (pd) ? (juD + yrD + shuoD - EquivalentStandardDay(y, 1, 0) - 1721425) : (juD - EquivalentStandardDay(y, 1, 0) - 1721425);
return vs;
}
/// <summary>
/// 返回阳历y年日差天数为x时所对应的月日数(如y=2000,x=274时,返回1001(表示10月1日,即返回100*m+d))
/// </summary>
private double AntiDayDifference(int y, double x)
{
int m = 1;
for (int j = 1; j <= 12; j++)
{
int mL = DayDifference(y, j + 1, 1) - DayDifference(y, j, 1);
if (x <= mL || j == 12)
{
m = j;
break;
}
else
x -= mL;
}
return 100 * m + x;
}
//原始:tail
/// <summary>
/// 返回x的小数尾数,若x为负值,则是1-小数尾数
/// </summary>
private double Tail(double x)
{
return x - Math.Floor(x);
}
//原始:ang
/// <summary>
/// 角度函数
/// </summary>
private double Angle(double x, double t, double c1, double t0, double t2, double t3)
{
return Tail(c1 * x) * 2 * Math.PI + t0 - t2 * t * t - t3 * t * t * t;
}
/// <summary>
/// 广义求余
/// </summary>
private double rem(double x, double w)
{
return Tail((x / w)) * w;
}
/// <summary>
/// 返回甲子数x对应的天干数(如33为3)
/// </summary>
private int Gan(int x)
{
return x % 10;
}
/// <summary>
/// 返回甲子数x对应的地支数(如33为9)
/// </summary>
private int Zhi(int x)
{
return x % 12;
}
/// <summary>
/// 获取指定日期的节气。
/// </summary>
/// <param name="year">要获取的年</param>
/// <param name="month">要获取的月</param>
/// <returns></returns>
/// <remarks>
/// 立春:立是开始的意思,春是蠢动,表示万物开始有生气,这一天春天开始。
/// 雨水:降雨开始,雨水将多。
/// 惊蛰:春雷响动,惊动蛰伏地下冬眠的生物,它们将开始出土活动。
/// 春分:这是春季九十天的中分点,这一天昼夜相等,所以古代曾称春分秋分为昼夜分。
/// 清明:明洁晴朗,气候温暖,草木开始萌发繁茂。
/// 谷雨:雨生百谷的意思。雨水增多,适时的降雨对谷物生长很为有利。
/// 立夏:夏天开始,万物渐将随温暖的气候而生长。
/// 小满:满指籽粒饱满,麦类等夏热作物这时开始结籽灌浆,即将饱满。
/// 芒种:有芒作物开始成熟,此时也是秋季作物播种的最繁忙时节。
/// 夏至:白天最长,黑夜最短,这一天中午太阳位置最高,日影短至终极,古代又称这一天为日北至或长日至。
/// 小暑:暑是炎热,此时还未到达最热。
/// 大暑:炎热的程度到达高峰。
/// 立秋:秋天开始,植物快成熟了。
/// 处暑:处是住的意思,表示暑气到此为止。
/// 白露:地面水气凝结为露,色白,是天气开始转凉了。
/// 秋分:秋季九十天的中间,这一天昼夜相等,同春分一样,太阳从正东升起正西落下。
/// 寒露:水露先白而后寒,是气候将逐渐转冷的意思。
/// 霜降:水气开始凝结成霜。
/// 立冬:冬是终了,作物收割后要收藏起来的意思,这一天起冬天开始。
/// 小雪:开始降雪,但还不多。
/// 大雪:雪量由小增大。
/// 冬至:这一天中午太阳在天空中位置最低,日影最长,白天最短, 黑夜最长,古代又称短日至或日南至。
/// 小寒:冷气积久而为寒,此时尚未冷到顶点。
/// 大寒:天候达到最寒冷的程度
/// </remarks>
public SolarTerm[] GetSolarTerm(int year, int month)
{
string[] lunarHoliDayName ={
"小寒", "大寒", "立春", "雨水","惊蛰", "春分", "清明", "谷雨","立夏", "小满", "芒种", "夏至",
"小暑", "大暑", "立秋", "处暑","白露", "秋分", "寒露", "霜降","立冬", "小雪", "大雪", "冬至"};
SolarTerm[] solarTerm = new SolarTerm[2];
for (int n = month * 2 - 1; n <= month * 2; n++)
{
SolarTerm st = new SolarTerm();
double dd = Term(year, n, true);
double sd1 = AntiDayDifference(2005, Math.Floor(dd));
double sm1 = Math.Floor(sd1 / 100);
int h = (int)Math.Floor((double)Tail(dd) * 24);
int min = (int)Math.Floor((double)(Tail(dd) * 24 - h) * 60);
int mmonth = (int)Math.Ceiling((double)n / 2);
int day = (int)sd1 % 100;
st.SolarTermDateTime = new DateTime(year, mmonth, day, h, min, 0);
st.Name = lunarHoliDayName[n - 1];
solarTerm[n - month * 2 + 1] = st;
}
return solarTerm;
}
/// <summary>
/// 获取指定日期的节气。
/// </summary>
/// <param name="solarDateTime"></param>
/// <returns></returns>
/// <remarks>我国农历里把节气分得很细,定出了二十四节气,它们的名称大都反应物候、农时或季节的起点与中点。由于节气实际反应太阳运行所引 起的气候变化,故二十四节气为阳历的自然衍生的产物,与阴历无关。二十四节气中以立春、春分、立夏,夏至、立秋、秋分、立冬与冬至等八节气最为重要。它们之间大约相隔46天。一年分为四季,「立」表示四季中每一个季节的开始,而「分」与「至」表示正处于这季节的中间。现代我国所使用的历法,皆依回归年制定,二十四节气基本上是一致的,前后的相差不会超过一两天。为了调合回归年(阳历)与朔望月(阴历)之间的差异,农历把二十四节气中,双数的叫中气,单数的叫节气,而且规定每一个中气标定在一个农历的月份,例如雨水必定在正月,春分必定在二月,谷雨必定在三月,其余依此类推。另外,月名也必须和相对应的中气相合。</remarks>
public SolarTerm[] GetSolarTerm(DateTime solarDateTime)
{
return GetSolarTerm(solarDateTime.Year, solarDateTime.Month);
}
#endregion
}//class
/// <summary>
/// 节气类
/// </summary>
public class SolarTerm
{
private DateTime solarTermDate;
private string name;
/// <summary>
/// 节气的时间。
/// </summary>
public DateTime SolarTermDateTime
{
get
{
return solarTermDate;
}
set
{
solarTermDate = value;
}
}
/// <summary>
/// 节气名。
/// </summary>
public string Name
{
get
{
return name;
}
set
{
name = value;
}
}
}//class SolarTerm
#region 花甲枚举
/// <summary>
/// 花甲枚举
/// </summary>
public enum ChineseEra
{
甲子 = 1, 乙丑 = 2, 丙寅 = 3, 丁卯 = 4, 戊辰 = 5, 己巳 = 6, 庚午 = 7, 辛未 = 8, 壬申 = 9, 癸酉 = 10, 甲戌 = 11, 乙亥 = 12,
丙子 = 13, 丁丑 = 14, 戊寅 = 15, 己卯 = 16, 庚辰 = 17, 辛巳 = 18, 壬午 = 19, 癸未 = 20, 甲申 = 21, 乙酉 = 22, 丙戌 = 23, 丁亥 = 24,
戊子 = 25, 己丑 = 26, 庚寅 = 27, 辛卯 = 28, 壬辰 = 29, 癸巳 = 30, 甲午 = 31, 乙未 = 32, 丙申 = 33, 丁酉 = 34, 戊戌 = 35, 己亥 = 36,
庚子 = 37, 辛丑 = 38, 壬寅 = 39, 癸卯 = 40, 甲辰 = 41, 乙巳 = 42, 丙午 = 43, 丁未 = 44, 戊申 = 45, 己酉 = 46, 庚戌 = 47, 辛亥 = 48,
壬子 = 49, 癸丑 = 50, 甲寅 = 51, 乙卯 = 52, 丙辰 = 53, 丁巳 = 54, 戊午 = 55, 己未 = 56, 庚申 = 57, 辛酉 = 58, 壬戌 = 59, 癸亥 = 60
};
#endregion
}//namespace