/// <summary> /// 根据时间戳取得时间点信息 /// </summary> /// <returns></returns> public static DateTime ToDatetime(this long time, TimeStampAccuracy accuracy = TimeStampAccuracy.Secound) { long accuracyNumber = long.Parse((10000000 / Math.Pow(10, (double)accuracy)).ToString()); long ticks = time * accuracyNumber + 621355968000000000; DateTime dt = DateTime.FromFileTime(ticks); return dt; }
/// <summary> /// 用于取得时间戳信息,精确到——秒 /// </summary> /// <returns></returns> public static long ToTimeStamp(this DateTime time, TimeStampAccuracy accuracy= TimeStampAccuracy.Secound) { long accuracyNumber = long.Parse((10000000 / Math.Pow(10, (double)accuracy)).ToString()); return (time.ToUniversalTime().Ticks - 621355968000000000) / accuracyNumber; }