///<summary>
/// 取得農曆日期
///</summary>
public static string GetLeapDate(DateTime Date, bool bShowYear = true, bool bShowMonth = true)
{
int L_ly, nLeapYear, nLeapMonth;
ChineseLunisolarCalendar MyChineseLunisolarCalendar = new ChineseLunisolarCalendar();
nLeapYear = MyChineseLunisolarCalendar.GetYear(Date);
nLeapMonth = MyChineseLunisolarCalendar.GetMonth(Date);
if (MyChineseLunisolarCalendar.IsLeapYear(nLeapYear)) //判斷此農曆年是否為閏年
{
L_ly = MyChineseLunisolarCalendar.GetLeapMonth(nLeapYear); //抓出此閏年閏何月
if (nLeapMonth >= L_ly)
{
nLeapMonth--;
}
}
else
{
nLeapMonth = MyChineseLunisolarCalendar.GetMonth(Date);
}
if (bShowYear)
{
return "" + MyChineseLunisolarCalendar.GetYear(Date) + "/" + nLeapMonth + "/" + MyChineseLunisolarCalendar.GetDayOfMonth(Date);
}
else if (bShowMonth)
{
return "" + nLeapMonth + "/" + MyChineseLunisolarCalendar.GetDayOfMonth(Date);
}
else
{
return "" + MyChineseLunisolarCalendar.GetDayOfMonth(Date);
}
}
///<summary>
/// 取得某一日期的該農曆月份的總天數
///</summary>
public static string GetDaysInLeapMonth(DateTime date)
{
ChineseLunisolarCalendar MyChineseLunisolarCalendar = new ChineseLunisolarCalendar();
return "" + MyChineseLunisolarCalendar.GetDaysInMonth(MyChineseLunisolarCalendar.GetYear(date), date.Month);
}
沒有留言:
張貼留言