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 未返回所需的值。"); }
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 未返回所需的值。"); }
/// <summary> /// 获取干支 /// </summary> /// <returns>干支</returns> public string getGanZhi() { if (index < 1) { return(""); } int offset = LunarUtil.getJiaZiIndex(lunar.getMonthInGanZhiExact()); offset += yun.isForward() ? index : -index; int size = LunarUtil.JIA_ZI.Length; if (offset >= size) { offset -= size; } if (offset < 0) { offset += size; } return(LunarUtil.JIA_ZI[offset]); }
public string getMonth() { return(lunar.getMonthInGanZhiExact()); }