using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Text;
|
|
namespace JiepeiWMS.Extends
|
{
|
/// <summary>
|
/// 数值扩展
|
/// </summary>
|
public static class ExtNumber
|
{
|
/// <summary>
|
/// 时间戳(秒级)转换日期
|
/// </summary>
|
/// <param name="Value">数值</param>
|
/// <param name="Hour">正8区</param>
|
/// <returns></returns>
|
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;
|
}
|
/// <summary>
|
/// 时间戳(毫秒级)转换日期
|
/// </summary>
|
/// <param name="Value">数值</param>
|
/// <param name="Hour">正8区</param>
|
/// <returns></returns>
|
public static DateTime _ToTimestampTimeByMs(this Int64 Value, int Hour = 8)
|
{
|
var val = Value * 10000;
|
var tm = new DateTime(val).AddHours(Hour);
|
return tm;
|
}
|
/// <summary>
|
/// 转换成字节
|
/// </summary>
|
/// <param name="Value">数值</param>
|
/// <returns>字节数组</returns>
|
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;
|
}
|
|
}
|
|
}
|