公历转为农历的函数
2013-10-11 15:17
253 查看
/// <summary> /// 公历转为农历的函数 /// </summary> /// <param name="solarDateTime">公历日期</param> /// <returns>农历的日期</returns> static string SolarToChineseLunisolarDate(DateTime solarDateTime) { System.Globalization.ChineseLunisolarCalendar cal = new System.Globalization.ChineseLunisolarCalendar(); int year = cal.GetYear(solarDateTime); int month = cal.GetMonth(solarDateTime); int day = cal.GetDayOfMonth(solarDateTime); int leapMonth = cal.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] // ); return string.Format("农历{0}月{1}{2}" , "无正二三四五六七八九十冬腊"[leapMonth > 0 && leapMonth <= month ? month - 1 : month] , "初十廿三"[day / 10] , "日一二三四五六七八九"[day % 10] ); }
相关文章推荐
- SQL Server公历转农历函数
- delphi 公历转农历函数
- PHP 公历转农历函数
- SQLServer公历转农历函数(1900年-2049年)
- C# 阳历转阴历函数 公历转农历函数
- 公历转换成农历的函数
- SQLServer公历转农历函数(1900年-2049年)
- 把公历转为农历
- SQLServer公历转农历函数(1900年-2049年)
- 公历转农历函数
- 农历 公历 互转函数(包括节气获取)
- 公历转农历函数
- oracle农历转公历函数
- 阴阳日历转换 公历日期转农历 八字排日柱算法
- 十六进制,八进制,十进制数转为二进制数显示的函数
- 中国公历算法&中国农历算法(JAVA)
- 中将中文转为拼音首字母的函数及调用方法
- 公历转农历模块,虽然是js文件,不过还是提供了实现方法,感谢提供者。
- 公历转农历linux C程序
- 阴阳日历转换 公历日期转农历 八字排日柱算法