namespace System
...{
/**//// <summary>
/// 中国常用农历日期时间类
/// zj53hao@qq.com http://hi.csdn.net/zj53hao
/// </summary>
class ChinaDateTime
...{
private int year, month, dayOfMonth;
private bool isLeap;
public DateTime time;
/**//// <summary>
/// 获取当前日期的农历年
/// </summary>
public int Year
...{
get ...{ return year; }
}
/**//// <summary>
/// 获取当前日期的农历月份
/// </summary>
public int Month
...{
get ...{ return month; }
}
/**//// <summary>
/// 获取当前日期的农历月中天数
/// </summary>
public int DayOfMonth
...{
get ...{ return dayOfMonth; }
}
/**//// <summary>
/// 获取当前日期是否为闰月中的日期
/// </summary>
public bool IsLeap
...{
get ...{ return isLeap; }
}
System.Globalization.ChineseLunisolarCalendar cc;
/**//// <summary>
/// 返回指定公历日期的阴历时间
/// </summary>
/// <param name="time"></param>
public ChinaDateTime(DateTime time)
...{
cc = new System.Globalization.ChineseLunisolarCalendar();
if (time > cc.MaxSupportedDateTime || time < cc.MinSupportedDateTime)
throw new Exception("参数日期时间不在支持的范围内,支持范围:" + cc.MinSupportedDateTime.ToShortDateString()+"到"+cc.MaxSupportedDateTime.ToShortDateString());
year = cc.GetYear(time);
month = cc.GetMonth(time);
dayOfMonth = cc.GetDayOfMonth(time);
isLeap = cc.IsLeapMonth(year, month);
if (isLeap) month -= 1;
this.time = time;
}
欢迎访问最专业的网吧论坛,无盘论坛,网吧经营,网咖管理,网吧专业论坛
https://bbs.txwb.com
关注天下网吧微信/下载天下网吧APP/天下网吧小程序,一起来超精彩
|
本文来源:来自网络 作者:佚名