time.hpp 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. // time.hpp --------------------------------------------------------------//
  2. // Copyright 2010 Vicente J. Botet Escriba
  3. // Distributed under the Boost Software License, Version 1.0.
  4. // See http://www.boost.org/LICENSE_1_0.txt
  5. #ifndef BOOST_DETAIL_WINAPI_TIME_HPP
  6. #define BOOST_DETAIL_WINAPI_TIME_HPP
  7. #include <boost/detail/winapi/basic_types.hpp>
  8. #ifdef BOOST_HAS_PRAGMA_ONCE
  9. #pragma once
  10. #endif
  11. namespace boost {
  12. namespace detail {
  13. namespace winapi {
  14. #if defined( BOOST_USE_WINDOWS_H )
  15. typedef FILETIME FILETIME_;
  16. typedef PFILETIME PFILETIME_;
  17. typedef LPFILETIME LPFILETIME_;
  18. typedef SYSTEMTIME SYSTEMTIME_;
  19. typedef SYSTEMTIME* PSYSTEMTIME_;
  20. #ifdef BOOST_HAS_GETSYSTEMTIMEASFILETIME // Windows CE does not define GetSystemTimeAsFileTime
  21. using ::GetSystemTimeAsFileTime;
  22. #endif
  23. using ::FileTimeToLocalFileTime;
  24. using ::GetSystemTime;
  25. using ::SystemTimeToFileTime;
  26. using ::GetTickCount;
  27. #else
  28. extern "C" {
  29. typedef struct _FILETIME {
  30. DWORD_ dwLowDateTime;
  31. DWORD_ dwHighDateTime;
  32. } FILETIME_, *PFILETIME_, *LPFILETIME_;
  33. typedef struct _SYSTEMTIME {
  34. WORD_ wYear;
  35. WORD_ wMonth;
  36. WORD_ wDayOfWeek;
  37. WORD_ wDay;
  38. WORD_ wHour;
  39. WORD_ wMinute;
  40. WORD_ wSecond;
  41. WORD_ wMilliseconds;
  42. } SYSTEMTIME_, *PSYSTEMTIME_;
  43. #ifdef BOOST_HAS_GETSYSTEMTIMEASFILETIME // Windows CE does not define GetSystemTimeAsFileTime
  44. __declspec(dllimport) void WINAPI
  45. GetSystemTimeAsFileTime(FILETIME_* lpFileTime);
  46. #endif
  47. __declspec(dllimport) int WINAPI
  48. FileTimeToLocalFileTime(const FILETIME_* lpFileTime,
  49. FILETIME_* lpLocalFileTime);
  50. __declspec(dllimport) void WINAPI
  51. GetSystemTime(SYSTEMTIME_* lpSystemTime);
  52. __declspec(dllimport) int WINAPI
  53. SystemTimeToFileTime(const SYSTEMTIME_* lpSystemTime,
  54. FILETIME_* lpFileTime);
  55. __declspec(dllimport) DWORD_ WINAPI
  56. GetTickCount();
  57. }
  58. #endif
  59. #ifndef BOOST_HAS_GETSYSTEMTIMEASFILETIME
  60. inline void WINAPI GetSystemTimeAsFileTime(FILETIME_* lpFileTime)
  61. {
  62. SYSTEMTIME_ st;
  63. GetSystemTime(&st);
  64. SystemTimeToFileTime(&st, lpFileTime);
  65. }
  66. #endif
  67. }
  68. }
  69. }
  70. #endif // BOOST_DETAIL_WINAPI_TIME_HPP