zoukankan      html  css  js  c++  java
  • 公历获取生肖和公历获取农历

            /// <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)));
            }
  • 相关阅读:
    模拟测试20190806
    替罪羊树学习日记
    [Usaco2015 Jan]Moovie Mooving
    [NOIP2016]愤怒的小鸟
    [BZOJ1556]墓地秘密
    [SDOI2009]学校食堂Dining
    [SCOI2008]奖励关
    [洛谷3930]SAC E#1
    [BZOJ2809/APIO2012]dispatching
    [Usaco2018 Open]Disruption
  • 原文地址:https://www.cnblogs.com/wangbogo/p/3008479.html
Copyright © 2011-2022 走看看