有时候我们在写程序时要用到中国的农历日期,网上已经有很多C#的农历类,但看来都很复杂,其实C#中已经提供了中国的农历类ChineseLunisolarCalendar。但未提供节气和节日功能。有网友根据网上的方法字节写了一个中国农历类,挺不错的,微酷在这里分享一下。
ChinaDate.GetChinaDate(DateTime dt) 获取农历日期
ChinaDate.GetYear(DateTime dt) 获取农历年份(包含天干地支和生肖信息)
ChinaDate.GetMonth(DateTime dt) 获取农历月份
ChinaDate.GetDay(DateTime dt) 获取农历日期
ChinaDate.GetSolarTerm(DateTime dt) 获取节气
ChinaDate.GetHoliday(DateTime dt) 获取公历节日
ChinaDate.GetChinaHoliday(DateTime dt) 获取农历节日
C# 中国农历类下载:C#中国农历类.ChinaDate.zip
原文作者:http://www.cnblogs.com/zjfree/archive/2011/01/13/1934662.html