DateTimeInternal.h 3.1 KB

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