using System;
namespace DFEngine.Utils
{
///
/// Class that contains different time functions.
///
public class Time
{
///
/// Represents the current system time in milliseconds.
///
public static long Milliseconds => DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
///
/// Represents the current system time in seconds.
///
public static long Seconds => DateTimeOffset.UtcNow.ToUnixTimeSeconds();
public static int GetTimeStamp(DateTime time)
{
return Convert.ToInt32((time - new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Local)).TotalSeconds);
}
public static DateTime UnixTimeStampToDateTime(double unixTimeStamp)
{
return new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc).AddSeconds(unixTimeStamp).ToLocalTime();
}
}
}