diff --git a/Facepunch.Steamworks/SteamApps.cs b/Facepunch.Steamworks/SteamApps.cs index 6a3da81..aef7fb9 100644 --- a/Facepunch.Steamworks/SteamApps.cs +++ b/Facepunch.Steamworks/SteamApps.cs @@ -95,7 +95,7 @@ namespace Steamworks /// /// Returns the time of the purchase of the app /// - public static DateTime PurchaseTime( AppId appid ) => Utility.Epoch.ToDateTime( Internal.GetEarliestPurchaseUnixTime( appid.Value ) ); + public static DateTime PurchaseTime( AppId appid ) => Epoch.ToDateTime( Internal.GetEarliestPurchaseUnixTime( appid.Value ) ); /// /// Checks if the user is subscribed to the current app through a free weekend diff --git a/Facepunch.Steamworks/SteamUtils.cs b/Facepunch.Steamworks/SteamUtils.cs index afbb7da..00ec7c1 100644 --- a/Facepunch.Steamworks/SteamUtils.cs +++ b/Facepunch.Steamworks/SteamUtils.cs @@ -68,7 +68,7 @@ namespace Steamworks /// /// Steam server time. Number of seconds since January 1, 1970, GMT (i.e unix time) /// - public static DateTime SteamServerTime => Utility.Epoch.ToDateTime( Internal.GetServerRealTime() ); + public static DateTime SteamServerTime => Epoch.ToDateTime( Internal.GetServerRealTime() ); /// /// returns the 2 digit ISO 3166-1-alpha-2 format country code this client is running in (as looked up via an IP-to-location database) diff --git a/Facepunch.Steamworks/Utility/Epoch.cs b/Facepunch.Steamworks/Utility/Epoch.cs new file mode 100644 index 0000000..2810a6e --- /dev/null +++ b/Facepunch.Steamworks/Utility/Epoch.cs @@ -0,0 +1,36 @@ +using System; + +namespace Steamworks +{ + static internal class Epoch + { + private static readonly DateTime epoch = new DateTime( 1970, 1, 1, 0, 0, 0, DateTimeKind.Utc ); + + /// + /// Returns the current Unix Epoch + /// + public static int Current + { + get + { + return (int)(DateTime.UtcNow.Subtract( epoch ).TotalSeconds); + } + } + + /// + /// Convert an epoch to a datetime + /// + public static DateTime ToDateTime( decimal unixTime ) + { + return epoch.AddSeconds( (long)unixTime ); + } + + /// + /// Convert a DateTime to a unix time + /// + public static uint FromDateTime( DateTime dt ) + { + return (uint)(dt.Subtract( epoch ).TotalSeconds); + } + } +} diff --git a/Facepunch.Steamworks/Utility/Utility.cs b/Facepunch.Steamworks/Utility/Utility.cs index dea6bed..dee9c43 100644 --- a/Facepunch.Steamworks/Utility/Utility.cs +++ b/Facepunch.Steamworks/Utility/Utility.cs @@ -7,7 +7,7 @@ using System.Text; namespace Steamworks { - public static partial class Utility + public static partial class Utility { static internal uint Swap( uint x ) { @@ -27,39 +27,6 @@ namespace Steamworks return new IPAddress( Swap( ipAddress ) ); } - static internal class Epoch - { - private static readonly DateTime epoch = new DateTime( 1970, 1, 1, 0, 0, 0, DateTimeKind.Utc ); - - /// - /// Returns the current Unix Epoch - /// - public static int Current - { - get - { - return (int)( DateTime.UtcNow.Subtract( epoch ).TotalSeconds ); - } - } - - /// - /// Convert an epoch to a datetime - /// - public static DateTime ToDateTime( decimal unixTime ) - { - return epoch.AddSeconds( (long)unixTime ); - } - - /// - /// Convert a DateTime to a unix time - /// - public static uint FromDateTime( DateTime dt ) - { - return (uint)( dt.Subtract( epoch ).TotalSeconds ); - } - - } - internal static string FormatPrice(string currency, ulong price) { return FormatPrice(currency, price / 100.0);