DateTimeInternal.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. //-------------------------------------------------------------------------------------------------------
  2. // Copyright (C) Microsoft. All rights reserved.
  3. // Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
  4. //-------------------------------------------------------------------------------------------------------
  5. #ifndef RUNTIME_PLATFORM_AGNOSTIC_DATETIME_INTERNAL
  6. #define RUNTIME_PLATFORM_AGNOSTIC_DATETIME_INTERNAL
  7. #include "Core/CommonTypedefs.h"
  8. namespace PlatformAgnostic
  9. {
  10. namespace DateTime
  11. {
  12. struct YMD;
  13. #define DateTimeTicks_PerSecond 1000.0
  14. #define DateTimeTicks_PerMinute (60 * DateTimeTicks_PerSecond)
  15. #define DateTimeTicks_PerHour (60 * DateTimeTicks_PerMinute)
  16. #define DateTimeTicks_PerDay (DateTimeTicks_PerHour * 24)
  17. #define DateTimeTicks_PerLargestTZOffset (DateTimeTicks_PerDay + 1)
  18. #define DateTimeTicks_PerNonLeapYear (DateTimeTicks_PerDay * 365)
  19. #define DateTimeTicks_PerSafeEndOfYear (DateTimeTicks_PerNonLeapYear - DateTimeTicks_PerLargestTZOffset)
  20. #ifdef _WIN32
  21. class TimeZoneInfo // DateTime.cpp
  22. {
  23. public:
  24. double daylightDate;
  25. double standardDate;
  26. double january1;
  27. double nextJanuary1;
  28. int32 daylightBias;
  29. int32 standardBias;
  30. int32 bias;
  31. uint32 lastUpdateTickCount;
  32. bool isDaylightTimeApplicable;
  33. bool isJanuary1Critical;
  34. TimeZoneInfo();
  35. bool IsValid(const double time);
  36. void Update(const double time);
  37. };
  38. struct DaylightTimeHelperPlatformData // DaylightHelper.cpp
  39. {
  40. TimeZoneInfo cache1, cache2;
  41. bool useFirstCache;
  42. };
  43. class UtilityPlatformData
  44. {
  45. public:
  46. TIME_ZONE_INFORMATION timeZoneInfo;
  47. uint32 lastTimeZoneUpdateTickCount;
  48. void UpdateTimeZoneInfo();
  49. UtilityPlatformData(): lastTimeZoneUpdateTickCount(0) { }
  50. };
  51. class HiresTimerPlatformData
  52. {
  53. public:
  54. double dBaseTime;
  55. double dLastTime;
  56. double dAdjustFactor;
  57. uint64 baseMsCount;
  58. uint64 freq;
  59. bool fReset;
  60. bool fInit;
  61. bool fHiResAvailable;
  62. HiresTimerPlatformData(): fInit(false), dBaseTime(0),
  63. baseMsCount(0), fHiResAvailable(true),
  64. dLastTime(0), dAdjustFactor(1), fReset(true) {}
  65. void Reset() { fReset = true; }
  66. };
  67. #else // ! _WIN32
  68. typedef void* DaylightTimeHelperPlatformData;
  69. #define __CC_PA_TIMEZONE_ABVR_NAME_LENGTH 32
  70. struct UtilityPlatformData
  71. {
  72. // cache always the last date's zone
  73. WCHAR standardName[__CC_PA_TIMEZONE_ABVR_NAME_LENGTH];
  74. size_t standardNameLength;
  75. };
  76. class HiresTimerPlatformData
  77. {
  78. public:
  79. double cacheSysTime;
  80. ULONGLONG cacheTick;
  81. ULONGLONG previousDifference;
  82. HiresTimerPlatformData():cacheSysTime(0), cacheTick(-1), previousDifference(0) { }
  83. void Reset() { /* dummy method for interface compatiblity */ }
  84. };
  85. #endif // ! _WIN32
  86. } // namespace DateTime
  87. } // namespace PlatformAgnostic
  88. #endif // RUNTIME_PLATFORM_AGNOSTIC_DATETIME_INTERNAL