Example #1
0
        private IEnumerable <ShiYun> 起大运(HHTime birthday)
        {
            DateTime?     dayunTime = birthday.Type == HHTime.TimeType.时间 ? LnBase.起运时间(birthday.DateTime, this.方向) : (DateTime?)null;
            List <ShiYun> dayuns    = new List <ShiYun>();

            ShiYun dyVor = new ShiYun(this.四柱.月.Add(0), ShiYun.YunType.大运, this.time.Bazi);

            dyVor.Start = birthday.Type == HHTime.TimeType.时间 ? birthday.DateTime : (DateTime?)null;
            dyVor.End   = dayunTime;
            dyVor.起小运  += this.起小运;
            dyVor.起流年  += this.起流年;
            dayuns.Add(dyVor);

            int f = this.方向 == 方向.顺行 ? 1 : -1;

            for (int i = 1; i <= 10; i++)
            {
                ShiYun dy = new ShiYun(this.四柱.月.Add(f * i), ShiYun.YunType.大运, this.time.Bazi);
                if (dayunTime != null)
                {
                    dy.Start = ((DateTime)dayunTime).AddYears(10 * (i - 1));
                    dy.End   = ((DateTime)dayunTime).AddYears(10 * i);
                    dy.起小运  += this.起小运;
                    dy.起流年  += this.起流年;
                }

                dayuns.Add(dy);
            }

            return(dayuns);
        }
Example #2
0
        public static DateTime 起运时间(DateTime birthday, 方向 direction)
        {
            // 阳男阴女顺行
            TimeSpan ts = LnBase.计算节气时间差(birthday, direction);

            DateTime dayun = birthday.AddYears((int)(Math.Abs(ts.Days) / 3));
            int      days  = Math.Abs(ts.Days) % 3;

            dayun = dayun.AddDays(days * 120 + Math.Abs(ts.Hours) * 5);
            dayun = dayun.AddDays((int)(Math.Abs(ts.Minutes) / 12));

            return(dayun);
        }
Example #3
0
        public static HuangLi 黄历日(LnDate date)
        {
            HuangLi huanli = new HuangLi();

            huanli.忌日 |= LnBase.Calc岁破(date);
            huanli.忌日 |= LnBase.Calc月破(date);
            huanli.忌日 |= LnBase.Calc上朔(date);
            huanli.忌日 |= LnBase.Calc杨公忌日(date);

            GanZhi yue = new GanZhi(date.MonthGZ);
            GanZhi ri  = new GanZhi(date.DayGZ);

            huanli.建除 = JianChu.Get(yue.Zhi, ri.Zhi);
            return(huanli);
        }
Example #4
0
        public static TimeSpan 计算节气时间差(DateTime date, 方向 f)
        {
            LnDate   节气日  = LnBase.查找节气(date.Year, date.Month);
            DateTime 具体时间 = 节气日.datetime + 节气日.JieQiTime;

            if (f == 方向.顺行 && date > 具体时间)
            {
                节气日 = LnBase.查找节气(date.Year, date.Month + 1);
            }
            else if (f == 方向.逆行 && date < 具体时间)
            {
                节气日 = LnBase.查找节气(date.Year, date.Month - 1);
            }

            具体时间 = 节气日.datetime + 节气日.JieQiTime;
            return(具体时间 - date);
        }
Example #5
0
        private IEnumerable <ShiYun> 起流年(DateTime start, DateTime end)
        {
            List <ShiYun> res = new List <ShiYun>();

            for (int i = 0; i <= 10; i++)
            {
                LnDate d  = new LnDate(start.AddYears(i));
                ShiYun ln = new ShiYun(new GanZhi(d.YearGZ), ShiYun.YunType.流年, this.time.Bazi);

                LnDate 立春 = LnBase.查找节气(start.AddYears(i).Year, 2);
                ln.Start = 立春.datetime + 立春.JieQiTime;
                ln.End   = ((DateTime)ln.Start).AddYears(1);

                res.Add(ln);

                // 超过时限,退出。主要是为起运前的流年考虑的。其它都是十年期。
                if (((DateTime)ln.End).Year > end.Year)
                {
                    break;
                }
            }

            return(res);
        }