1 /// 从儒略日转换为年月日(如把54863转换为2009-02-01) 2 /// </summary> 3 /// <param name="mjdstr">简化儒略日</param> 4 /// <returns>年-月-日</returns> 5 #if 1 6 void GetDateTimeByMJD(u32_t mjdstr) 7 { 8 //把简化儒略日转换为儒略日(MJD TO JD) 9 double xdata JD = (double)(mjdstr) + 2400000.5; 10 double xdata Z = floor(JD + 0.5); 11 double xdata W = floor((Z - 1867216.25) / 36524.25); 12 double xdata X = floor(W / 4); 13 double xdata AA = floor(Z + 1 + W - X); 14 double xdata BB = floor(AA + 1524); 15 double xdata CC = floor((BB - 122.1) / 365.25); 16 double xdata DD = floor(365.25 * CC); 17 double xdata EE = floor((BB - DD) / 30.6001); 18 double xdata FF = floor(30.6001 * EE); 19 date.Day = BB - DD - FF; 20 // double Month; 21 // double Year; 22 if ((EE - 13) <= 12 && (EE - 13) > 0) 23 date.Month = EE - 13; 24 else 25 date.Month = EE - 1; 26 if (date.Month == 1 || date.Month == 2) 27 date.Year = CC - 4715; 28 else 29 date.Year = CC - 4716; 30 31 } 32 33 /// 从日期获得儒略日 34 /// </summary> 35 /// <param name="dt">时间</param> 36 /// <returns>简化儒略日mjd</returns> 37 u32_t GetMJd(T_DATA dt) 38 { 39 long I = dt.Year, J = dt.Month, K = dt.Day; 40 //求出给定年(I),月(J),日(K)的儒略日: 41 double jd = K - 32075 + 1461 * (I + 4800 + (J - 14) / 12) / 4 + 367 * (J - 2 - (J - 14) / 12 * 12) / 12 - 3 * ((I + 4900 + (J - 14) / 12) / 100) / 4; 42 u32_t mjdStr = (jd - 2400000.5); 43 return mjdStr; 44 // int x = mjdStr.IndexOf("."); 45 // if (x == -1) 46 // { 47 // return long.Parse(mjdStr); 48 // } 49 // else 50 // { 51 // mjdStr = mjdStr.Substring(0, x); 52 // return long.Parse(mjdStr); 53 // } 54 }