コード例 #1
0
        /// <summary>
        /// 获取干支
        /// </summary>
        /// <returns>干支</returns>
        public string getGanZhi()
        {
            int offset = LunarUtil.getJiaZiIndex(lunar.getYearInGanZhiExact()) + this.index;

            if (daYun.getIndex() > 0)
            {
                offset += daYun.getStartAge() - 1;
            }
            offset %= LunarUtil.JIA_ZI.Length;
            return(LunarUtil.JIA_ZI[offset]);
        }
コード例 #2
0
        public void test3()
        {
            int year   = 2020;
            int month  = 1;
            int day    = 20;
            int hour   = 13;
            int minute = 22;
            int second = 0;

            Solar solar = new Solar(year, month, day, hour, minute, second);
            Lunar lunar = solar.getLunar();

            Assert.AreEqual("己亥", lunar.getYearInGanZhi(), "getYearInGanZhi 未返回所需的值。");
            Assert.AreEqual("己亥", lunar.getYearInGanZhiByLiChun(), "getYearInGanZhiByLiChun 未返回所需的值。");
            Assert.AreEqual("己亥", lunar.getYearInGanZhiExact(), "getYearInGanZhiExact 未返回所需的值。");

            Assert.AreEqual("丁丑", lunar.getMonthInGanZhi(), "getMonthInGanZhi 未返回所需的值。");
            Assert.AreEqual("丁丑", lunar.getMonthInGanZhiExact(), "getMonthInGanZhiExact 未返回所需的值。");
        }
コード例 #3
0
        public void test19()
        {
            int year   = 1986;
            int month  = 5;
            int day    = 6;
            int hour   = 23;
            int minute = 22;
            int second = 0;

            Solar solar = new Solar(year, month, day, hour, minute, second);
            Lunar lunar = solar.getLunar();

            Assert.AreEqual("丙寅", lunar.getYearInGanZhi(), "getYearInGanZhi 未返回所需的值。");
            Assert.AreEqual("丙寅", lunar.getYearInGanZhiByLiChun(), "getYearInGanZhiByLiChun 未返回所需的值。");
            Assert.AreEqual("丙寅", lunar.getYearInGanZhiExact(), "getYearInGanZhiExact 未返回所需的值。");

            Assert.AreEqual("癸巳", lunar.getMonthInGanZhi(), "getMonthInGanZhi 未返回所需的值。");
            Assert.AreEqual("癸巳", lunar.getMonthInGanZhiExact(), "getMonthInGanZhiExact 未返回所需的值。");
        }
コード例 #4
0
 public string getYear()
 {
     return(lunar.getYearInGanZhiExact());
 }