ISystemClock.cs 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. using Ryujinx.Core.OsHle.Ipc;
  2. using System;
  3. using System.Collections.Generic;
  4. namespace Ryujinx.Core.OsHle.Objects.Time
  5. {
  6. class ISystemClock : IIpcInterface
  7. {
  8. private Dictionary<int, ServiceProcessRequest> m_Commands;
  9. public IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands;
  10. private static DateTime Epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
  11. private SystemClockType ClockType;
  12. public ISystemClock(SystemClockType ClockType)
  13. {
  14. m_Commands = new Dictionary<int, ServiceProcessRequest>()
  15. {
  16. { 0, GetCurrentTime }
  17. };
  18. this.ClockType = ClockType;
  19. }
  20. public long GetCurrentTime(ServiceCtx Context)
  21. {
  22. DateTime CurrentTime = DateTime.Now;
  23. if (ClockType == SystemClockType.User ||
  24. ClockType == SystemClockType.Network)
  25. {
  26. CurrentTime = CurrentTime.ToUniversalTime();
  27. }
  28. Context.ResponseData.Write((long)(DateTime.Now - Epoch).TotalSeconds);
  29. return 0;
  30. }
  31. }
  32. }