公历获取生肖和公历获取农历
2013-04-08 17:28
288 查看
/// <summary> /// 根据月份和日期计算星座 /// </summary> /// <param name="month"></param> /// <param name="day"></param> /// <returns></returns> public string GetXingZuoByMonthAndDay(int month, int day) { string s = "魔羯水瓶双鱼白羊金牛双子巨蟹狮子处女天秤天蝎射手魔羯"; int[] arr = { 20, 19, 21, 21, 21, 22, 23, 23, 23, 23, 22, 22 }; return s.Substring(month * 2 - (day < arr[month - 1] ? 2 : 0), 2); } ///<summary> /// 根据公历获取农历日期 ///</summary> ///<param name="datetime">公历日期</param> ///<returns>农历日期</returns> public static DateTime GetChineseDateTime(DateTime datetime) { System.Globalization.ChineseLunisolarCalendar cd = new System.Globalization.ChineseLunisolarCalendar(); int year = cd.GetYear(datetime); int month = cd.GetMonth(datetime); int leapMonth = cd.GetLeapMonth(year); if (leapMonth > 0 && leapMonth <= month) month--; return DateTime.Parse(string.Format("{0}-{1}-{2} {3}:{4}:{5}", year, month, cd.GetDayOfMonth(datetime), cd.GetHour(datetime), cd.GetMinute(datetime), cd.GetSecond(datetime))); }
相关文章推荐
- iOS 获取公历、农历日期的年月日
- iOS 获取公历、农历日期的年月日的实例代码
- iOS 获取公历、农历日期的年月日
- Android获取公历年/月/日/星期 + 农历月/日
- 农历 公历 互转函数(包括节气获取)
- WindowsPhone 中 根据公历 获取农历日期数据
- C#实现万年历(农历、节气、节日、星座、星宿、属相、生肖、闰年月、时辰)
- C#实现万年历(农历、节气、节日、星座、星宿、属相、生肖、闰年月、时辰)
- Andorid 之日历控件,可左右滑动,包含公历,农历,节假日等
- 公历转农历linux C程序
- 【Java开发】中国的公历转农历-工具类
- Javascript获取当前日期的农历日期代码
- JS获取农历日期
- 公历转换中国农历的算法--ChineseCalendarGB.java
- qt实现公历转农历,C++亦可用
- 公历转农历
- SQLServer公历转农历函数(1900年-2049年)
- PHP汉字拼音转换和公历农历转换(代码家园)
- JavaScript实现1900-2100区间内的公历、农历互转
- 公历转农历