原來還准備自己寫算法
using System;
using System
using System
namespace System
/**//// <summary>
/// 中國常用農歷日期時間類
///
/// </summary>
class ChinaDateTime
private int year
private bool isLeap;
public DateTime time;
/**//// <summary>
/// 獲取當前日期的農歷年
/// </summary>
public int Year
get
}
/**//// <summary>
/// 獲取當前日期的農歷月份
/// </summary>
public int Month
get
}
/**//// <summary>
/// 獲取當前日期的農歷月中天數
/// </summary>
public int DayOfMonth
get
}
/**//// <summary>
/// 獲取當前日期是否為閏月中的日期
/// </summary>
public bool IsLeap
get
}
System
/**//// <summary>
/// 返回指定公歷日期的陰歷時間
/// </summary>
/// <param name=
public ChinaDateTime(DateTime time)
cc = new System
if (time > cc
throw new Exception(
year = cc
month = cc
dayOfMonth = cc
isLeap = cc
if (isLeap) month
this
}
/**//// <summary>
/// 返回當前日前的農歷日期
/// </summary>
public static ChinaDateTime Now
get
}
/**//// <summary>
/// 返回指定農歷年
/// </summary>
/// <param name=
/// <param name=
/// <param name=
/// <param name=
public ChinaDateTime(int Year
if (Year >= cc
throw new Exception(
if (Month <
throw new Exception(
cc = new System
if(cc
throw new Exception(
if (cc
throw new Exception(
year = Year;
month = Month;
dayOfMonth = DayOfMonth;
isLeap = IsLeap;
time = DateTime
}
/**//// <summary>
/// 獲取當前農歷日期的公歷時間
/// </summary>
public DateTime ToDateTime()
return cc
}
/**//// <summary>
/// 獲取指定農歷時間對應的公歷時間
/// </summary>
/// <param name=
/// <returns></returns>
public static DateTime ToDateTime(ChinaDateTime CnTime)
return CnTime
}
/**//// <summary>
/// 獲取指定公歷時間轉換為農歷時間
/// </summary>
/// <param name=
/// <returns></returns>
public static ChinaDateTime ToChinaDateTime(DateTime Time)
return new ChinaDateTime(Time);
}
/**//// <summary>
From:http://tw.wingwit.com/Article/program/net/201311/11671.html