Пример #1
0
        private BaZiList <GanZhi> InitBaZiFromDateTime(DateTime date, bool 确定时辰)
        {
            this.datetime = new LnDate(date);
            this.time     = 确定时辰 ? date.TimeOfDay : TimeSpan.Zero;

            GanZhi 年 = new GanZhi(this.datetime.YearGZ);
            GanZhi 月 = new GanZhi(this.datetime.MonthGZ);
            GanZhi 日 = new GanZhi(this.datetime.DayGZ);

            LnDate 明天 = this.datetime.Add(1);

            if (date.Hour >= 23)
            {
                日 = 日.Add(1);
                年 = new GanZhi(明天.YearGZ);
                月 = new GanZhi(明天.MonthGZ);
            }

            GanZhi 时 = GanZhi.Zero;

            if (确定时辰)
            {
                Zhi 时支 = Zhi.Get((int)((date.Hour + 1) / 2) % 12);
                时 = 日.Gan.起月时(时支, 柱位.时);
            }

            return(BaZiList.Create(年, 月, 日, 时));
        }
Пример #2
0
        /// <summary>
        /// 可以没有天干,但必须有地支。
        /// </summary>
        /// <param name="gan"></param>
        /// <param name="zhi"></param>
        public GanZhi(string gan, string zhi)
        {
            this.Gan = Gan.Get(gan);
            this.Zhi = Zhi.Get(zhi);

            this.ValidCheck();
        }
Пример #3
0
        public GanZhi(int gan, int zhi)
        {
            this.Gan = Gan.Get(gan);
            this.Zhi = Zhi.Get(zhi);

            this.ValidCheck();
        }
Пример #4
0
 internal string[] Calc(GanZhi gz)
 {
     if (this.CalcSpec == null)
     {
         return(new string[] { Zhi.Get(this.Pattern[this.Fetch(gz)]).Name });
     }
     else
     {
         return(this.CalcSpec(gz));
     }
 }
Пример #5
0
        internal static string[] 贵人(GanZhi gz)
        {
            int[,] pattern = new int[10, 2] {
                { 1, 7 }, { 8, 0 }, { 11, 9 }, { 11, 9 }, { 1, 7 }, { 8, 0 }, { 2, 6 }, { 2, 6 }, { 3, 5 }, { 3, 5 }
            };

            List <int> res = new List <int>();

            res.Add(pattern[gz.Gan.Index, 0]);
            res.Add(pattern[gz.Gan.Index, 1]);

            return(res.Select(i => Zhi.Get(i).Name).ToArray());
        }
Пример #6
0
        public GanZhi(string name)
        {
            string g = string.Empty;
            string z = string.Empty;

            if (string.IsNullOrEmpty(name) || name.Length > 2)
            {
                this.Gan = Gan.Zero;
                this.Zhi = Zhi.Zero;
            }
            else if (name.Length == 1)
            {
                this.Gan = Gan.Zero;
                this.Zhi = Zhi.Get(name);
            }
            else
            {
                this.Gan = Gan.Get(name.Substring(0, 1));
                this.Zhi = Zhi.Get(name.Substring(1, 1));
            }

            this.ValidCheck();
        }
Пример #7
0
        internal static string[] 旬空(GanZhi gz)
        {
            var index = 10 - (int)(gz.Index / 10) * 2;

            return(new string[] { Zhi.Get(index).Name, Zhi.Get(index + 1).Name });
        }
Пример #8
0
 internal static string[] 天医(GanZhi gz)
 {
     return(new string[] { Zhi.Get((gz.Zhi.Index - 1 + 12) % 12).Name });
 }