/// <summary> /// 日上起时干 /// </summary> /// <param name="rg">日干</param> /// <param name="sc">时辰</param> /// <returns>时干</returns> private TianGan GetTimeGan(TianGanTypes rg, DiZhiTypes sc) { int sc1 = ((int)sc) - 1; TianGanTypes tg; if ((rg == TianGanTypes.Jia) || (rg == TianGanTypes.Ji)) { tg = TianGanTypes.Jia; } else if ((rg == TianGanTypes.Yi) || (rg == TianGanTypes.Geng)) { tg = TianGanTypes.Bing; } else if ((rg == TianGanTypes.Bing) || (rg == TianGanTypes.Xin)) { tg = TianGanTypes.Wu; } else if ((rg == TianGanTypes.Ding) || (rg == TianGanTypes.Ren)) { tg = TianGanTypes.Geng; } else { tg = TianGanTypes.Ren; } TianGan t = new TianGan(tg); return(t.Inc(sc1)); }
/// <summary> /// 获取增加指定的数值后的干支实例 /// </summary> /// <param name="i">增加的数值</param> /// <returns>干支</returns> public GanZhi Inc(int i) { TianGan t = _tg.Inc(i); DiZhi d = _dz.Inc(i); return(new GanZhi(t, d)); }
/// <summary> /// 年上取月干 /// </summary> /// <param name="ng">年干</param> /// <param name="m1">农历月份</param> /// <returns>月干</returns> private TianGan GetMonthGanByYear(TianGanTypes ng, int m1) //年上取月干 { int m = Math.Abs(m1); TianGanTypes tg; if ((ng == TianGanTypes.Jia) || (ng == TianGanTypes.Ji)) { tg = TianGanTypes.Bing; } else if ((ng == TianGanTypes.Yi) || (ng == TianGanTypes.Geng)) { tg = TianGanTypes.Wu; } else if ((ng == TianGanTypes.Bing) || (ng == TianGanTypes.Xin)) { tg = TianGanTypes.Geng; } else if ((ng == TianGanTypes.Ding) || (ng == TianGanTypes.Ren)) { tg = TianGanTypes.Ren; } else { tg = TianGanTypes.Jia; } TianGan t = new TianGan(tg); return(t.Inc(m - 1)); }
private TianGan GetTimeGan(TianGanTypes rg, DiZhiTypes sc) { TianGanTypes jia; int i = ((int)sc) - 1; if ((rg == TianGanTypes.Jia) || (rg == TianGanTypes.Ji)) { jia = TianGanTypes.Jia; } else if ((rg == TianGanTypes.Yi) || (rg == TianGanTypes.Geng)) { jia = TianGanTypes.Bing; } else if ((rg == TianGanTypes.Bing) || (rg == TianGanTypes.Xin)) { jia = TianGanTypes.Wu; } else if ((rg == TianGanTypes.Ding) || (rg == TianGanTypes.Ren)) { jia = TianGanTypes.Geng; } else { jia = TianGanTypes.Ren; } TianGan gan = new TianGan(jia); return(gan.Inc(i)); }
private TianGan GetMonthGanByYear(TianGanTypes ng, int m1) { TianGanTypes bing; int num = Math.Abs(m1); if ((ng == TianGanTypes.Jia) || (ng == TianGanTypes.Ji)) { bing = TianGanTypes.Bing; } else if ((ng == TianGanTypes.Yi) || (ng == TianGanTypes.Geng)) { bing = TianGanTypes.Wu; } else if ((ng == TianGanTypes.Bing) || (ng == TianGanTypes.Xin)) { bing = TianGanTypes.Geng; } else if ((ng == TianGanTypes.Ding) || (ng == TianGanTypes.Ren)) { bing = TianGanTypes.Ren; } else { bing = TianGanTypes.Jia; } TianGan gan = new TianGan(bing); return(gan.Inc(num - 1)); }
/// <summary> /// 取某天的日干 /// </summary> /// <param name="dt">日期</param> /// <returns>日干</returns> private TianGan GetDayGan(DateTime dt) { System.DateTime dt1 = new System.DateTime(2000, 2, 5, 12, 0, 0, 0);//以2000.2.5为基准 System.DateTime dt2 = new System.DateTime(dt.Year, dt.Month, dt.Day, 12, 0, 0, 0); int n = (dt2 - dt1).Days; TianGan tg = new TianGan(TianGanTypes.Gui); return(tg.Inc(n)); }
private TianGan GetDayGan(DateTime dt) { DateTime time = new DateTime(0x7d0, 2, 5, 12, 0, 0, 0); DateTime time2 = new DateTime(dt.Year, dt.Month, dt.Day, 12, 0, 0, 0); TimeSpan span = (TimeSpan)(time2 - time); int days = span.Days; TianGan gan = new TianGan(TianGanTypes.Gui); return(gan.Inc(days)); }
private TianGan GetYearTianGan(int y) { int i = y - 0x7d0; TianGan gan = new TianGan(TianGanTypes.Geng); if (i == 0) { return(gan); } return(gan.Inc(i)); }
/// <summary> /// 取指定公历年的天干 /// </summary> /// <param name="y">年份</param> /// <returns>天干</returns> private TianGan GetYearTianGan(int y) { int i = y - 2000;//以2000年为基准 TianGan tg = new TianGan(TianGanTypes.Geng); if (i == 0) { return(tg); } else { return(tg.Inc(i)); } }
private TianGan GetYearTianGan(int y) { int i = y - 0x7d0; TianGan gan = new TianGan(TianGanTypes.Geng); if (i == 0) { return gan; } return gan.Inc(i); }
private TianGan GetTimeGan(TianGanTypes rg, DiZhiTypes sc) { TianGanTypes jia; int i = ((int) sc) - 1; if ((rg == TianGanTypes.Jia) || (rg == TianGanTypes.Ji)) { jia = TianGanTypes.Jia; } else if ((rg == TianGanTypes.Yi) || (rg == TianGanTypes.Geng)) { jia = TianGanTypes.Bing; } else if ((rg == TianGanTypes.Bing) || (rg == TianGanTypes.Xin)) { jia = TianGanTypes.Wu; } else if ((rg == TianGanTypes.Ding) || (rg == TianGanTypes.Ren)) { jia = TianGanTypes.Geng; } else { jia = TianGanTypes.Ren; } TianGan gan = new TianGan(jia); return gan.Inc(i); }
private TianGan GetMonthGanByYear(TianGanTypes ng, int m1) { TianGanTypes bing; int num = Math.Abs(m1); if ((ng == TianGanTypes.Jia) || (ng == TianGanTypes.Ji)) { bing = TianGanTypes.Bing; } else if ((ng == TianGanTypes.Yi) || (ng == TianGanTypes.Geng)) { bing = TianGanTypes.Wu; } else if ((ng == TianGanTypes.Bing) || (ng == TianGanTypes.Xin)) { bing = TianGanTypes.Geng; } else if ((ng == TianGanTypes.Ding) || (ng == TianGanTypes.Ren)) { bing = TianGanTypes.Ren; } else { bing = TianGanTypes.Jia; } TianGan gan = new TianGan(bing); return gan.Inc(num - 1); }
private TianGan GetDayGan(DateTime dt) { DateTime time = new DateTime(0x7d0, 2, 5, 12, 0, 0, 0); DateTime time2 = new DateTime(dt.Year, dt.Month, dt.Day, 12, 0, 0, 0); TimeSpan span = (TimeSpan) (time2 - time); int days = span.Days; TianGan gan = new TianGan(TianGanTypes.Gui); return gan.Inc(days); }