也可以封装一个类使其能够直接返回农历日期,并且可读性更高
Lunar.LunarDateld=newLunar.GetLunarDate(2022,3,29);或者使用下面的代码块直接获取当日农历日期:
Lunar.LunarDateld=Lunar.GetLunarDate();其中,LunarDate类中的属性Month为农历月,Day为农历日,IsLeap为是否为闰月,其定义如下(Program.cs中也有):
publicstructLunarDate{publicintMonth;publicintDay;publicboolIsLeap;}同样,也可以使用下面的代码块确定某个日期是否在农历的闰月中:
boolisLeapMonth=Lunar.IsLeap(2022,3,29);或者使用下面的代码块直接获取当日时候在农历的闰月中:
boolisLeapMonth=Lunar.IsLeap();除此以外,还可以使用下面的代码块直接获取当前日期的农历日期的字符串表示:
LunarMonthCalendar.LunarDateld=newLunarMonthCalendar.LunarDate();ld=LunarMonthCalendar.GetLunarDate(2000,4,5);其中LunarDate类中的属性Month为农历月,Day为农历日,IsLeap为是否为闰月.定义如下:
publicstaticclassLunarDate{publicintMonth;publicintDay;publicbooleanIsLeap;}也可使用单一IsLeap()判定是否为闰月
直接运行就行不要瞎改因为我也不知道它为什么能运行
一个简单、高效的将公历(阳历)日期转化为农历(阴历)日期的算法