Beispiel #1
0
        public IActionResult DateChineseName()
        {
            ChineseCalendar.ChineseCalendar calendar = new ChineseCalendar.ChineseCalendar();
            var lunarDateName = calendar.GetLunarDateName();

            return(Ok(lunarDateName));
        }
        /// <summary>
        ///     将指定的年份数加到此农历日期上
        /// </summary>
        /// <param name="n">年份</param>
        /// <returns>农历日期</returns>
        public ChineseCalendar AddYears(int n)
        {
            ChineseCalendar temp = this;

            temp.LunarYear       += n;
            temp.IsLunarLeapMonth = false;
            temp._lunarYearString = null;
            temp._sexagenary      = null;
            temp._animal          = null;
            int days = GetDaysInMonth(temp.LunarYear, temp.LunarMonth);

            if (days < LunarDay)
            {
                temp.LunarDay        = days;
                temp._lunarDayString = null;
            }

            return(temp);
        }
        /// <summary>
        ///     将指定的月份数加到此农历日期上
        /// </summary>
        /// <param name="n">月份数</param>
        /// <returns>农历日期</returns>
        public ChineseCalendar AddMonths(int n)
        {
            var temp = new ChineseCalendar(_solarDate);

            for (int i = 0; i < n; i++)
            {
                temp.SolarDate = temp._solarDate.AddDays(29);
                if (temp.LunarMonth == LunarMonth &&
                    (IsLunarLeapMonth || (IsLunarLeapMonth == false &&
                                          temp.IsLunarLeapMonth == false)))
                {
                    temp.LunarMonth++;
                    temp._lunarMonthString = null;
                }

                int days = GetDaysInMonth(temp.LunarYear, temp.LunarMonth);
                temp.LunarDay = days < LunarDay ? days : LunarDay;

                temp._lunarDayString = null;
            }

            return(temp);
        }