diff --git a/Facepunch.Steamworks/Utility.cs b/Facepunch.Steamworks/Utility.cs index 6546416..0e4593b 100644 --- a/Facepunch.Steamworks/Utility.cs +++ b/Facepunch.Steamworks/Utility.cs @@ -14,5 +14,30 @@ namespace Facepunch.Steamworks ( ( x & 0x00ff0000 ) >> 8 ) + ( ( x & 0xff000000 ) >> 24 ); } + + 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 ); + } + + } } }