System Time Offset Implementation (#1101)
* System Time Offset Implementation * Addressed @Thog's comments * Addressed JD's comments * Addressed @Thog's and @AcK77's comments * formatting correction
This commit is contained in:
parent
e4ee61d6c3
commit
0a7c6caedf
8 changed files with 320 additions and 6 deletions
|
@ -1,4 +1,5 @@
|
|||
using System.Runtime.InteropServices;
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Services.Time.Clock
|
||||
{
|
||||
|
@ -9,6 +10,8 @@ namespace Ryujinx.HLE.HOS.Services.Time.Clock
|
|||
|
||||
public static readonly TimeSpanType Zero = new TimeSpanType(0);
|
||||
|
||||
private static readonly DateTime UnixEpoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
|
||||
|
||||
public long NanoSeconds;
|
||||
|
||||
public TimeSpanType(long nanoSeconds)
|
||||
|
@ -21,6 +24,16 @@ namespace Ryujinx.HLE.HOS.Services.Time.Clock
|
|||
return NanoSeconds / NanoSecondsPerSecond;
|
||||
}
|
||||
|
||||
public TimeSpanType AddSeconds(long seconds)
|
||||
{
|
||||
return new TimeSpanType(NanoSeconds + (seconds * NanoSecondsPerSecond));
|
||||
}
|
||||
|
||||
public bool IsDaylightSavingTime()
|
||||
{
|
||||
return UnixEpoch.AddSeconds(ToSeconds()).ToLocalTime().IsDaylightSavingTime();
|
||||
}
|
||||
|
||||
public static TimeSpanType FromSeconds(long seconds)
|
||||
{
|
||||
return new TimeSpanType(seconds * NanoSecondsPerSecond);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue