.NET 公历转农历
2009-09-07 09:46
204 查看
公历转农历得使用农历闰年闰月对照表
好在.NET已经预备了这个对照表,我们不用再去声明,可以直接使用
好在.NET已经预备了这个对照表,我们不用再去声明,可以直接使用
public string ChineseLunisolarDate(DateTime ADataTime) { var clc = new System.Globalization.ChineseLunisolarCalendar(); var year = clc.GetYear(ADataTime); var month = clc.GetMonth(ADataTime); var day = clc.GetDayOfMonth(ADataTime); var leapMonth = clc.GetLeapMonth(year); return string.Format("{0}{1} {2}年{3}{4}月{5}{6}" , "甲乙丙丁戊己庚辛壬癸"[(year - 4) % 10] , "子丑寅卯辰巳午未申酉戌亥"[(year - 4) % 12] , "鼠牛虎兔龙蛇马羊猴鸡狗猪"[(year - 4) % 12] , month == leapMonth ? "润" : "" , "无正二三四五六七八九十冬腊"[leapMonth > 0 && leapMonth <= month ? month - 1 : month] , "初十廿三"[day / 10] , "日一二三四五六七八九"[day % 10] ); } private void Form1_Load(object sender, EventArgs e) { dateTimePicker1_ValueChanged(dateTimePicker1, EventArgs.Empty); } private void dateTimePicker1_ValueChanged(object sender, EventArgs e) { textBox1.Text = ChineseLunisolarDate(((DateTimePicker)sender).Value); } //System.Globalization.EastAsianLunisolarCalendar //System.Globalization.TaiwanLunisolarCalendar //System.Globalization.ThaiBuddhistCalendar //System.Globalization.KoreanLunisolarCalendar //System.Globalization.JapaneseLunisolarCalendar //System.Globalization.HebrewCalendar //System.Globalization.HijriCalendar //System.Globalization.JapaneseCalendar
相关文章推荐
- 公历转换中国农历的算法--ChineseCalendarGB.java
- python工具代码之农历转换公历,公历转换农历神器持续更新:【内向即失败--王奕君】
- 用Delphi处理公历到农历的转换
- 发布一个简陋的公历转换农历小工具
- 当月的所有周日 倒计时显示当年剩下的天时分秒 公历转农历
- 由.Net类库提供的农历计算(C#农历)
- iOS 获取公历、农历日期的年月日
- iOS 获取公历、农历日期的年月日的实例代码
- Andorid 之日历控件,可左右滑动,包含公历,农历,节假日等
- 日历工具类(一)——公历农历互相转换
- PHP汉字拼音转换和公历农历转换
- “易语言.飞扬”公历转农历源码,作者ganjun3000
- 公历到农历的转换法
- 公历转换成农历的函数
- 用Delphi处理公历到农历的转换
- SQL Server公历转农历函数
- python3实现万年历(包括公历、农历、节气、节日)
- c#版公历转农历
- [转]SAP ABAP实现农历转成公历(With Code Sample)
- JAVA农历转公历,公历转农历算法