System.Globalization.ChineseLunisolarCalendar.GetEra C# (CSharp) Method

GetEra() private method

private GetEra ( System.DateTime time ) : int
time System.DateTime
return int
        public override int GetEra(DateTime time) {
            CheckTicksRange(time.Ticks);
            return (ChineseEra);
        }

Usage Example

        /// <summary>
        /// 返回指定公历日期对应的农历月
        /// </summary>
        /// <param name="calendar"></param>
        /// <param name="date"></param>
        /// <returns></returns>
        public static string GetLunisolarMonth(this ChineseLunisolarCalendar calendar, DateTime date)
        {
            var month     = calendar.GetMonth(date);
            var leapMonth = calendar.GetLeapMonth(calendar.GetYear(date), calendar.GetEra(date));
            var isleep    = leapMonth > 0 && leapMonth == month;

            if (leapMonth > 0)
            {
                if (leapMonth <= month)
                {
                    month--;
                }
            }

            return(string.Concat(isleep ? "闰" : string.Empty, GetLunisolarMonth(month), "月"));
        }