DDR爱好者之家 Design By 杰米
#region 得到一个月的第一天和最后一天的日期
/// <summary>
/// 得到本月的第一天日期
/// </summary>
/// <returns>DateTime</returns>
public static DateTime GetFirstDayOfMonth()
{
return GetFirstDayOfMonth(DateTime.Now);
}
/// <summary>
/// 得到本月的最有一天的日期
/// </summary>
/// <returns>DateTime</returns>
public static DateTime GetLastDayOfMonth()
{
return GetLastDayOfMonth(DateTime.Now);
}
/// <summary>
/// 得到一个月的第一天
/// </summary>
/// <param name="someday">这个月的随便一天</param>
/// <returns>DateTime</returns>
public static DateTime GetFirstDayOfMonth(DateTime someday)
{
int totalDays = DateTime.DaysInMonth(someday.Year, someday.Month);
DateTime result;
int ts = 1 - someday.Day;
result = someday.AddDays(ts);
return result;
}
/// <summary>
/// 得到一个月的最后一天
/// </summary>
/// <param name="someday">这个月的随便一天</param>
/// <returns>DateTime</returns>
public static DateTime GetLastDayOfMonth(DateTime someday)
{
int totalDays = DateTime.DaysInMonth(someday.Year, someday.Month);
DateTime result;
int ts = totalDays - someday.Day;
result = someday.AddDays(ts);
return result;
}
#endregion
DDR爱好者之家 Design By 杰米
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
DDR爱好者之家 Design By 杰米