namespace Alchemy.Core.Extensions { public static class LongExtension { /// /// MB转Byte /// /// /// public static long MbToByte(this long value) { return value * (long)1024 * (long)1024; } /// /// 时间戳转DateTime /// /// /// public static DateTime ToDateTime(this long timeStamp) { DateTime dt = new DateTime(2000, 1, 1, 0, 0, 0); try { dt = DateTimeOffset.FromUnixTimeSeconds(timeStamp).LocalDateTime; } catch (Exception ex) { throw new Exception(ex.Message); } return dt; } /// /// 时间戳转DateTimeUtc /// /// /// public static DateTime ToDateTimeUtc(this long timeStamp) { DateTime dt = new DateTime(2000, 1, 1, 0, 0, 0); try { dt = DateTimeOffset.FromUnixTimeSeconds(timeStamp).DateTime; } catch (Exception ex) { throw new Exception(ex.Message); } return dt; } } }