using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace JiepeiWMS.Extends { /// /// 数值扩展 /// public static class ExtNumber { /// /// 时间戳(秒级)转换日期 /// /// 数值 /// 正8区 /// public static DateTime _ToTimestampTime(this Int64 Value, int Hour = 8) { var dt = new DateTime(1970, 1, 1); var val = Value * 10000000; var tm = dt.AddTicks(val).AddHours(Hour); return tm; } /// /// 时间戳(毫秒级)转换日期 /// /// 数值 /// 正8区 /// public static DateTime _ToTimestampTimeByMs(this Int64 Value, int Hour = 8) { var val = Value * 10000; var tm = new DateTime(val).AddHours(Hour); return tm; } /// /// 转换成字节 /// /// 数值 /// 字节数组 public static byte[] _ToBytes(this ulong Value) { byte[] bytes = new byte[8]; bytes[7] = (byte)(Value & 0xFF); bytes[6] = (byte)(Value >> 8 & 0xFF); bytes[5] = (byte)(Value >> 16 & 0xFF); bytes[4] = (byte)(Value >> 24 & 0xFF); bytes[3] = (byte)(Value >> 32 & 0xFF); bytes[2] = (byte)(Value >> 40 & 0xFF); bytes[1] = (byte)(Value >> 48 & 0xFF); bytes[0] = (byte)(Value >> 56 & 0xFF); return bytes; } } }