ServerDataManager.cs 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. using System;
  2. namespace GFGGame
  3. {
  4. public class ServerDataManager
  5. {
  6. private const long TIME_ORIGINAL = 621355968000000000;
  7. private static long _dTime;
  8. public static void SetServerTime(long serverTime)
  9. {
  10. _dTime = serverTime - CurrentlocalTime;
  11. }
  12. public static long currentTimeMillis
  13. {
  14. get
  15. {
  16. return CurrentlocalTime + _dTime;
  17. }
  18. }
  19. public static int currentTimeSecs
  20. {
  21. get
  22. {
  23. return (int)currentTimeMillis/1000;
  24. }
  25. }
  26. public static long CurrentlocalTime
  27. {
  28. get
  29. {
  30. return (DateTime.Now.Ticks - TIME_ORIGINAL)/10000;
  31. }
  32. }
  33. public static int CurrentDay {
  34. get
  35. {
  36. DateTime dateTime = new DateTime(currentTimeMillis*10000 + TIME_ORIGINAL);
  37. return dateTime.Day;
  38. }
  39. }
  40. }
  41. }