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.

55 lines
2.0 KiB

  1. #pragma once
  2. #include <windows.h>
  3. #include <stdlib.h>
  4. #include <tchar.h>
  5. #include <limits.h>
  6. #include <mistsafe.h>
  7. #define ARRAYSIZE(a) (sizeof(a)/sizeof(a[0]))
  8. const TCHAR EOS = _T('\0');
  9. const WCHAR WEOS = L'\0';
  10. const int NanoSec100PerSec = 10000000; // number of 100 nanoseconds per second
  11. ////////////////////////////////////////////////////////////////////////////
  12. //
  13. // Function TimeDiff(tm1, tm2)
  14. // helper function to find the difference (in seconds) of 2 system times
  15. //
  16. // Input: 2 SYSTEMTIME structures
  17. // Output: None
  18. // Return: seconds of difference
  19. // > 0 if tm2 is later than tm1
  20. // = 0 if tm2 and tm1 are the same
  21. // < 0 if tm2 is earlier than tm1
  22. //
  23. // On error the function returns 0 even if the two times are not equal
  24. //
  25. // Comment: If the number of seconds goes beyond INT_MAX (that is
  26. // more than 24,855 days, INT_MAX is returned.
  27. // If the number of seconds goes beyond INT_MIN (a negative value,
  28. // means 24,855 days ago), INT_MIN is returned.
  29. //
  30. ////////////////////////////////////////////////////////////////////////////
  31. int TimeDiff(SYSTEMTIME tm1, SYSTEMTIME tm2);
  32. ////////////////////////////////////////////////////////////////////////////
  33. //
  34. // Function TimeAddSeconds(SYSTEMTIME, int, SYSTEMTIME* )
  35. // helper function to calculate time by adding n seconds to
  36. // the given time.
  37. //
  38. // Input: a SYSTEMTIME as base time, an int as seconds to add to the base time
  39. // Output: new time
  40. // Return: HRESULT
  41. //
  42. ////////////////////////////////////////////////////////////////////////////
  43. HRESULT TimeAddSeconds(SYSTEMTIME tmBase, int iSeconds, SYSTEMTIME* pTimeNew);
  44. //Function to convert a string buffer to system time
  45. HRESULT String2SystemTime(LPCTSTR pszDateTime, SYSTEMTIME *ptm);
  46. //Function to convert a system time structure to a string buffer
  47. HRESULT SystemTime2String(SYSTEMTIME & tm, LPTSTR pszDateTime, size_t cSize);