Ejemplo n.º 1
0
        /// <summary>
        /// 起运计算
        /// </summary>
        private void computeStart()
        {
            JieQi    prev          = lunar.getPrevJie();
            JieQi    next          = lunar.getNextJie();
            Solar    current       = lunar.getSolar();
            Solar    start         = forward ? current : prev.getSolar();
            Solar    end           = forward ? next.getSolar() : current;
            int      hourDiff      = LunarUtil.getTimeZhiIndex(end.toYmdHms().Substring(11, 5)) - LunarUtil.getTimeZhiIndex(start.toYmdHms().Substring(11, 5));
            DateTime endCalendar   = new DateTime(end.getYear(), end.getMonth(), end.getDay(), 0, 0, 0, 0);
            DateTime startCalendar = new DateTime(start.getYear(), start.getMonth(), start.getDay(), 0, 0, 0, 0);
            int      dayDiff       = endCalendar.Subtract(startCalendar).Days;

            if (hourDiff < 0)
            {
                hourDiff += 12;
                dayDiff--;
            }
            int monthDiff = hourDiff * 10 / 30;
            int month     = dayDiff * 4 + monthDiff;
            int day       = hourDiff * 10 - monthDiff * 30;
            int year      = month / 12;

            month           = month - year * 12;
            this.startYear  = year;
            this.startMonth = month;
            this.startDay   = day;
        }
Ejemplo n.º 2
0
        public void testConvert1()
        {
            Lunar lunar = new Lunar(2019, 12, 29);

            Assert.AreEqual("二〇一九年腊月廿九", lunar.ToString(), "com.nlf.calendar.Solar.getLunar 有错。");
            Assert.AreEqual("2020-01-23", lunar.getSolar().ToString(), "com.nlf.calendar.Lunar.getSolar 有错。");
        }
Ejemplo n.º 3
0
        public void testConvert()
        {
            Solar solar = new Solar(2020, 1, 23);
            Lunar lunar = solar.getLunar();

            Assert.AreEqual("二〇一九年腊月廿九", lunar.ToString(), "com.nlf.calendar.Solar.getLunar 有错。");
            Assert.AreEqual("2020-01-23", lunar.getSolar().ToString(), "com.nlf.calendar.Lunar.getSolar 有错。");
        }
Ejemplo n.º 4
0
        public DaYun(Yun yun, int index)
        {
            this.yun   = yun;
            this.lunar = yun.getLunar();
            this.index = index;
            int year = yun.getStartSolar().getYear();

            if (index < 1)
            {
                this.startYear = lunar.getSolar().getYear();
                this.startAge  = 1;
                this.endYear   = year - 1;
                this.endAge    = yun.getStartYear();
            }
            else
            {
                int add = (index - 1) * 10;
                this.startYear = year + add;
                this.startAge  = yun.getStartYear() + add + 1;
                this.endYear   = this.startYear + 9;
                this.endAge    = this.startAge + 9;
            }
        }