标签:style blog io color ar sp for div on
// System.DateTimeOffset [__DynamicallyInvokable] public static DateTimeOffset FromUnixTimeMilliseconds(long milliseconds) { if (milliseconds < -62135596800000L || milliseconds > 253402300799999L) { throw new ArgumentOutOfRangeException("milliseconds", string.Format(Environment.GetResourceString("ArgumentOutOfRange_Range"), -62135596800000L, 253402300799999L)); } long ticks = milliseconds * 10000L + 621355968000000000L; return new DateTimeOffset(ticks, TimeSpan.Zero); }
// System.DateTimeOffset [__DynamicallyInvokable] public static DateTimeOffset FromUnixTimeSeconds(long seconds) { if (seconds < -62135596800L || seconds > 253402300799L) { throw new ArgumentOutOfRangeException("seconds", string.Format(Environment.GetResourceString("ArgumentOutOfRange_Range"), -62135596800L, 253402300799L)); } long ticks = seconds * 10000000L + 621355968000000000L; return new DateTimeOffset(ticks, TimeSpan.Zero); }
// System.DateTimeOffset [__DynamicallyInvokable] public long ToUnixTimeMilliseconds() { long num = this.UtcDateTime.Ticks / 10000L; return num - 62135596800000L; }
// System.DateTimeOffset [__DynamicallyInvokable] public long ToUnixTimeSeconds() { long num = this.UtcDateTime.Ticks / 10000000L; return num - 62135596800L; }
为了这四个方法特意装了VS2015,你没看错,是2015
System.DateTimeOffset 中新增的Unix 时间戳方法
标签:style blog io color ar sp for div on
原文地址:http://www.cnblogs.com/binsys/p/4098363.html