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); }
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); }