mirror of
https://github.com/Facepunch/Facepunch.Steamworks.git
synced 2025-01-23 20:17:58 +03:00
Added Utility.Epoch
This commit is contained in:
parent
b8e6614f67
commit
6a5603a121
@ -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 );
|
||||
|
||||
/// <summary>
|
||||
/// Returns the current Unix Epoch
|
||||
/// </summary>
|
||||
public static int Current
|
||||
{
|
||||
get
|
||||
{
|
||||
return (int)( DateTime.UtcNow.Subtract( epoch ).TotalSeconds );
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Convert an epoch to a datetime
|
||||
/// </summary>
|
||||
public static DateTime ToDateTime( decimal unixTime )
|
||||
{
|
||||
return epoch.AddSeconds( (long)unixTime );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user