Source code of Windows XP (NT5)
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.

108 lines
3.5 KiB

  1. //#pragma title( "Common.hpp - Common classes of general utility" )
  2. /*
  3. Copyright (c) 1995-1998, Mission Critical Software, Inc. All rights reserved.
  4. ===============================================================================
  5. Module - Common.hpp
  6. System - Common
  7. Author - Tom Bernhardt, Rich Denham
  8. Created - 1994-08-22
  9. Description - Common classes of general utility.
  10. Updates - 1997-09-12 RED replace TTime class
  11. ===============================================================================
  12. */
  13. #ifndef MCSINC_Common_hpp
  14. #define MCSINC_Common_hpp
  15. // Start of header file dependencies
  16. #ifndef _INC_LIMITS
  17. #include <limits.h>
  18. #endif
  19. #ifndef _INC_STDIO
  20. #include <stdio.h>
  21. #endif
  22. #ifndef _INC_TIME
  23. #include <time.h>
  24. #endif
  25. #ifndef MCSINC_Mcs_h
  26. #include "Mcs.h"
  27. #endif
  28. // End of header file dependencies
  29. #define SECS(n) (n * 1000)
  30. #define DIM(array) (sizeof (array) / sizeof (array[0]))
  31. #ifdef UNICODE
  32. typedef unsigned short UTCHAR;
  33. #define UTEXT(quote) ((unsigned short *) (L##quote))
  34. #else
  35. typedef unsigned char UTCHAR;
  36. #define UTEXT(quote) ((unsigned char *) (quote))
  37. #endif // UNICODE
  38. #define UnNull(ptr) ( (ptr) ? (ptr) : (UCHAR *) "" )
  39. #define DAYSECS (24*60*60)
  40. class TTime
  41. {
  42. private:
  43. protected:
  44. public:
  45. time_t Now( // ret-current time
  46. time_t * pTime // out-optional current time
  47. ) const;
  48. #ifndef WIN16_VERSION
  49. __int64 NowAsFiletime( // ret-current time
  50. __int64 * pTime // out-optional current time
  51. ) const;
  52. time_t ConvertFiletimeToTimet( // ret-time_t representation
  53. __int64 fileTime // in -filetime representation
  54. ) const;
  55. #endif // WIN16_VERSION
  56. WCHAR * FormatIsoUtc( // ret-YYYY-MM-DD HH:MM:SS string
  57. time_t tTime ,// in -time_t representation
  58. WCHAR * sTime // out-YYYY-MM-DD HH:MM:SS string
  59. ) const;
  60. WCHAR * FormatIsoLcl( // ret-YYYY-MM-DD HH:MM:SS string
  61. time_t tTime ,// in -time_t representation
  62. WCHAR * sTime // out-YYYY-MM-DD HH:MM:SS string
  63. ) const;
  64. };
  65. extern
  66. TTime gTTime; // global instance of TTime
  67. #ifndef WIN16_VERSION
  68. __int64 // ret-numeric value of string
  69. TextToInt64(
  70. TCHAR const * str ,// in-string value to parse
  71. __int64 minVal ,// in -min allowed value for result
  72. __int64 maxVal ,// in -max allowed value for result
  73. char const ** errMsg // out-error message pointer or NULL
  74. );
  75. #endif // WIN16_VERSION
  76. typedef struct EaTimeZoneInfo
  77. { // all values are in seconds
  78. long bias; // time zone bias
  79. long dst; // daylight savings time bias
  80. long biasdst; // time zone bias including possible DST
  81. } EaTimeZoneInfo;
  82. // Return time zone information
  83. // If the returned value is TRUE, the EaTimeZoneInfo structure is filled in
  84. // If the returned value is FALSE, the EaTimeZoneInfo structure is all zeroes
  85. // Note: UTC (gTTime.Now( NULL )) minus pTimeZoneInfo->biasdst is the local date/time
  86. BOOL
  87. EaGetTimeZoneInfo(
  88. EaTimeZoneInfo * pTimeZoneInfo // in -time zone information
  89. );
  90. #endif // MCSINC_Common_hpp
  91. // Common.hpp - end of file