Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

137 lines
3.4 KiB

  1. /*++
  2. Copyright (C) 1996-2001 Microsoft Corporation
  3. Module Name:
  4. CWBEMTIME.H
  5. Abstract:
  6. Time helper
  7. History:
  8. --*/
  9. #ifndef __WBEM_TIME__H_
  10. #define __WBEM_TIME__H_
  11. #include "corepol.h"
  12. #define WBEMTIME_LENGTH 25
  13. class POLARITY CWbemInterval
  14. {
  15. protected:
  16. DWORD m_dwMs;
  17. CWbemInterval(DWORD dwMs) : m_dwMs(dwMs){}
  18. friend class CWbemTime;
  19. public:
  20. CWbemInterval() : m_dwMs(0){}
  21. static CWbemInterval GetInfinity() {return CWbemInterval(INFINITE);}
  22. BOOL IsFinite() const {return m_dwMs != INFINITE;}
  23. BOOL IsZero() const {return m_dwMs == 0;}
  24. DWORD GetMilliseconds() const {return m_dwMs;}
  25. DWORD GetSeconds() const {return m_dwMs/1000;}
  26. void SetMilliseconds(DWORD dwMs) {m_dwMs = dwMs;}
  27. BOOL operator<(const CWbemInterval Other)
  28. {return m_dwMs < Other.m_dwMs;}
  29. BOOL operator>(const CWbemInterval Other)
  30. {return m_dwMs > Other.m_dwMs;}
  31. CWbemInterval operator*(double dblFactor) const
  32. {return CWbemInterval((DWORD)(m_dwMs * dblFactor));}
  33. CWbemInterval operator+(const CWbemInterval Other) const
  34. {return CWbemInterval(m_dwMs + Other.m_dwMs);}
  35. void operator+=(const CWbemInterval Other)
  36. {m_dwMs += Other.m_dwMs;}
  37. };
  38. #define I64_INFINITY 0x7FFFFFFFFFFFFFFF
  39. class POLARITY CWbemTimeSpan
  40. {
  41. private:
  42. ULONGLONG m_Time;
  43. friend class CWbemTime;
  44. public:
  45. CWbemTimeSpan (
  46. int iDays ,
  47. int iHours ,
  48. int iMinutes ,
  49. int iSeconds ,
  50. int iMSec=0 ,
  51. int iUSec=0,
  52. int iNSec=0
  53. ) ;
  54. };
  55. class POLARITY CWbemTime
  56. {
  57. protected:
  58. __int64 m_i64;
  59. CWbemTime(__int64 i64) : m_i64(i64){}
  60. friend class CWbemInterval;
  61. public:
  62. CWbemTime() : m_i64(0){}
  63. CWbemTime(const CWbemTime& Other) : m_i64(Other.m_i64){}
  64. void operator=(const CWbemTime& Other)
  65. {
  66. m_i64 = Other.m_i64;
  67. }
  68. static CWbemTime GetCurrentTime();
  69. static CWbemTime GetInfinity() {return CWbemTime(I64_INFINITY);}
  70. static CWbemTime GetZero() {return CWbemTime(0);}
  71. BOOL SetSystemTime(const SYSTEMTIME& st);
  72. BOOL SetFileTime(const FILETIME& ft);
  73. BOOL GetSYSTEMTIME ( SYSTEMTIME *pst ) const;
  74. BOOL GetFILETIME ( FILETIME *pst ) const;
  75. __int64 Get100nss() const {return m_i64;}
  76. void Set100nss(__int64 i64) {m_i64 = i64;}
  77. CWbemInterval RemainsUntil(const CWbemTime& Other) const;
  78. BOOL IsFinite() const {return m_i64 != I64_INFINITY;}
  79. BOOL IsZero() const {return m_i64 == 0;}
  80. CWbemTime operator+ ( const CWbemTimeSpan &uAdd ) const ;
  81. CWbemTime operator- ( const CWbemTimeSpan &sub ) const;
  82. BOOL operator <(const CWbemTime& Other) const
  83. {return m_i64 < Other.m_i64;}
  84. BOOL operator >(const CWbemTime& Other) const
  85. {return m_i64 > Other.m_i64;}
  86. BOOL operator <=(const CWbemTime& Other) const
  87. {return m_i64 <= Other.m_i64;}
  88. BOOL operator >=(const CWbemTime& Other) const
  89. {return m_i64 >= Other.m_i64;}
  90. CWbemTime operator+(const CWbemInterval& ToAdd) const;
  91. CWbemInterval operator-(const CWbemTime& ToSubtract) const
  92. {return ToSubtract.RemainsUntil(*this);}
  93. BOOL SetDMTF(LPCWSTR wszText);
  94. static LONG GetLocalOffsetForDate(const SYSTEMTIME *pst);
  95. private:
  96. BOOL GetDMTF( BOOL bLocal, DWORD dwBuffLen, LPWSTR pwszBuff );
  97. };
  98. #endif