ace/Source/ACE.Common/Time.cs
Ty Conner 2fdb8387bb
Fix some issues with secure trade. (#1745)
* Fix some issues with secure trade.

* .

* Changes to ID failure return

* .

* Add rot to player sold to vendor items.

* change to configurable
2019-04-16 23:44:19 -05:00

33 lines
817 B
C#

using System;
namespace ACE.Common
{
public class Time
{
private static readonly DateTime unixEpoch = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
public static double GetUnixTime()
{
return GetUnixTime(DateTime.UtcNow);
}
public static double GetUnixTime(DateTime dateTime)
{
TimeSpan span = (dateTime - unixEpoch);
return span.TotalSeconds;
}
public static double GetFutureUnixTime(double seconds)
{
TimeSpan span = (DateTime.UtcNow.AddSeconds(seconds) - unixEpoch);
return span.TotalSeconds;
}
public static DateTime GetDateTimeFromTimestamp(double timestamp)
{
return unixEpoch.AddSeconds(timestamp);
}
}
}