Beispiel #1
0
        public void test6()
        {
            int year   = 2020;
            int month  = 2;
            int day    = 1;
            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 未返回所需的值。");
        }
Beispiel #2
0
        public void testDaYun()
        {
            int[]     startYears = { 1983, 1989, 1999, 2009, 2019, 2029, 2039, 2049, 2059, 2069 };
            int[]     endYears   = { 1988, 1998, 2008, 2018, 2028, 2038, 2048, 2058, 2068, 2078 };
            int[]     startAges  = { 1, 7, 17, 27, 37, 47, 57, 67, 77, 87 };
            int[]     endAges    = { 6, 16, 26, 36, 46, 56, 66, 76, 86, 96 };
            String[]  yearGanZhi = { "", "乙卯", "丙辰", "丁巳", "戊午", "己未", "庚申", "辛酉", "壬戌", "癸亥" };
            Solar     solar      = new Solar(1983, 2, 15, 20, 0, 0);
            Lunar     lunar      = solar.getLunar();
            EightChar bazi       = lunar.getEightChar();
            Yun       yun        = bazi.getYun(0);

            DaYun[] l = yun.getDaYun();
            for (int i = 0, j = l.Length; i < j; i++)
            {
                DaYun daYun = l[i];
                Assert.AreEqual(startYears[i], daYun.getStartYear());
                Assert.AreEqual(endYears[i], daYun.getEndYear());
                Assert.AreEqual(startAges[i], daYun.getStartAge());
                Assert.AreEqual(endAges[i], daYun.getEndAge());
                Assert.AreEqual(yearGanZhi[i], daYun.getGanZhi());
            }
        }
Beispiel #3
0
        static void Main(string[] args)
        {
            // ÑôÀú
            Solar solar = new Solar(2020, 5, 26, 23, 42, 0);

            Console.WriteLine(solar);
            Console.WriteLine(solar.toFullString());

            // ÒõÀú
            Lunar lunar = solar.getLunar();

            Console.WriteLine(lunar);
            Console.WriteLine(lunar.toFullString());

            // °Ë×Ö
            EightChar baZi = lunar.getEightChar();

            Console.WriteLine(baZi.getYear() + " " + baZi.getMonth() + " " + baZi.getDay() + " " + baZi.getTime());

            // °Ë×ÖÄÉÒô
            Console.WriteLine(baZi.getYearNaYin() + " " + baZi.getMonthNaYin() + " " + baZi.getDayNaYin() + " " + baZi.getTimeNaYin());

            // °Ë×ÖÎåÐÐ
            Console.WriteLine(baZi.getYearWuXing() + " " + baZi.getMonthWuXing() + " " + baZi.getDayWuXing() + " " + baZi.getTimeWuXing());

            // °Ë×ÖÌì¸ÉÊ®Éñ
            Console.WriteLine(baZi.getYearShiShenGan() + " " + baZi.getMonthShiShenGan() + " " + baZi.getDayShiShenGan() + " " + baZi.getTimeShiShenGan());

            // °Ë×ÖµØ֧ʮÉñ
            Console.WriteLine(baZi.getYearShiShenZhi()[0] + " " + baZi.getMonthShiShenZhi()[0] + " " + baZi.getDayShiShenZhi()[0] + " " + baZi.getTimeShiShenZhi()[0]);

            // °Ë×ÖÄê֧ʮÉñ
            foreach (string s in baZi.getYearShiShenZhi())
            {
                Console.Write(s + " ");
            }
            Console.WriteLine();

            // °Ë×ÖÔÂ֧ʮÉñ
            foreach (string s in baZi.getMonthShiShenZhi())
            {
                Console.Write(s + " ");
            }
            Console.WriteLine();

            // °Ë×ÖÈÕ֧ʮÉñ
            foreach (string s in baZi.getDayShiShenZhi())
            {
                Console.Write(s + " ");
            }
            Console.WriteLine();

            // °Ë×Öʱ֧ʮÉñ
            foreach (string s in baZi.getTimeShiShenZhi())
            {
                Console.Write(s + " ");
            }
            Console.WriteLine();

            // °Ë×ÖÌ¥Ôª
            Console.WriteLine(baZi.getTaiYuan());

            // °Ë×ÖÃü¹¬
            Console.WriteLine(baZi.getMingGong());

            // °Ë×ÖÉí¹¬
            Console.WriteLine(baZi.getShenGong());

            // ½Ú¼ÙÈÕ
            List <Holiday> holidays = HolidayUtil.getHolidays(2012);

            foreach (Holiday holiday in holidays)
            {
                Console.WriteLine(holiday);
            }
            Console.WriteLine();

            // °Ë×ÖתÑôÀú
            List <Solar> solars = Solar.fromBaZi("¸ý×Ó", "Îì×Ó", "¼ºÃ®", "¸ýÎç");

            foreach (Solar d in solars)
            {
                Console.WriteLine(d.toFullString());
            }
            Console.WriteLine();

            Console.ReadLine();
        }
Beispiel #4
0
        static void Main(string[] args)
        {
            // 阳历
            Solar solar = new Solar(2020, 5, 26, 23, 42, 0);

            Console.WriteLine(solar);
            Console.WriteLine(solar.toFullString());

            // 阴历
            Lunar lunar = solar.getLunar();

            Console.WriteLine(lunar);
            Console.WriteLine(lunar.toFullString());

            // 八字
            EightChar baZi = lunar.getEightChar();

            Console.WriteLine(baZi.getYear() + " " + baZi.getMonth() + " " + baZi.getDay() + " " + baZi.getTime());

            // 八字纳音
            Console.WriteLine(baZi.getYearNaYin() + " " + baZi.getMonthNaYin() + " " + baZi.getDayNaYin() + " " + baZi.getTimeNaYin());

            // 八字五行
            Console.WriteLine(baZi.getYearWuXing() + " " + baZi.getMonthWuXing() + " " + baZi.getDayWuXing() + " " + baZi.getTimeWuXing());

            // 八字天干十神
            Console.WriteLine(baZi.getYearShiShenGan() + " " + baZi.getMonthShiShenGan() + " " + baZi.getDayShiShenGan() + " " + baZi.getTimeShiShenGan());

            // 八字地支十神
            Console.WriteLine(baZi.getYearShiShenZhi()[0] + " " + baZi.getMonthShiShenZhi()[0] + " " + baZi.getDayShiShenZhi()[0] + " " + baZi.getTimeShiShenZhi()[0]);

            // 八字年支十神
            foreach (string s in baZi.getYearShiShenZhi())
            {
                Console.Write(s + " ");
            }
            Console.WriteLine();

            // 八字月支十神
            foreach (string s in baZi.getMonthShiShenZhi())
            {
                Console.Write(s + " ");
            }
            Console.WriteLine();

            // 八字日支十神
            foreach (string s in baZi.getDayShiShenZhi())
            {
                Console.Write(s + " ");
            }
            Console.WriteLine();

            // 八字时支十神
            foreach (string s in baZi.getTimeShiShenZhi())
            {
                Console.Write(s + " ");
            }
            Console.WriteLine();

            // 八字胎元
            Console.WriteLine(baZi.getTaiYuan());

            // 八字命宫
            Console.WriteLine(baZi.getMingGong());

            // 八字身宫
            Console.WriteLine(baZi.getShenGong());

            Console.WriteLine();
            solar = new Solar(1988, 3, 20, 18, 0, 0);
            lunar = solar.getLunar();
            EightChar bazi = lunar.getEightChar();

            // 男运
            Yun yun = bazi.getYun(1);

            Console.WriteLine("阳历" + solar.toYmdHms() + "出生");
            Console.WriteLine("出生" + yun.getStartYear() + "年" + yun.getStartMonth() + "个月" + yun.getStartDay() + "天后起运");
            Console.WriteLine("阳历" + yun.getStartSolar().toYmd() + "后起运");
            Console.WriteLine();

            // 节假日
            List <Holiday> holidays = HolidayUtil.getHolidays(2012);

            foreach (Holiday holiday in holidays)
            {
                Console.WriteLine(holiday);
            }
            Console.WriteLine();

            // 八字转阳历
            List <Solar> solars = Solar.fromBaZi("庚子", "戊子", "己卯", "庚午");

            foreach (Solar d in solars)
            {
                Console.WriteLine(d.toFullString());
            }
            Console.WriteLine();

            Console.ReadLine();
        }