摘要:農曆日期算法
TaiwanLunisolarCalendar 類別
命名空間: System.Globalization
DateTime dt = DateTime.Now;
TaiwanLunisolarCalendar tlc = new TaiwanLunisolarCalendar();
int _year = tlc.GetYear(dt);
int _month = tlc.GetMonth(dt);
int _day = tlc.GetDayOfMonth(dt);
int _monthDays = tlc.GetDaysInMonth(_year, _month);
//以下是計算閏月
int leapMonth = tlc.GetLeapMonth(_year);
if (leapMonth > 0 && _month <= leapMonth)
{
if (leapMonth == _month)
{
_month = leapMonth - 1;
}
}
else if (leapMonth > 0 && _month > leapMonth)
{
_month = _month - 1;
}