MRPT  1.9.9
xstime.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | https://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2019, Individual contributors, see AUTHORS file |
6  | See: https://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See: https://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 #ifndef XSTIME_H
10 #define XSTIME_H
11 
12 #include "xstypesconfig.h"
13 #ifdef _WIN32
14 #include <windows.h>
15 #endif
16 
17 #include <time.h>
18 #include "pstdint.h"
19 #include "xstimestamp.h"
20 
21 #ifdef __cplusplus
22 #include "xsstring.h"
23 extern "C"
24 {
25 #endif
26 
30 
32  XsTime_getTimeOfDay(struct tm* date_, time_t* secs_);
35  char* dest, struct tm const* date);
36  // XSTYPES_DLL_API void XsTime_getTimeAsString(char* dest, struct tm const*
37  // time);
38  // XSTYPES_DLL_API void XsTime_getDateAsWString(
39  // wchar_t* dest, struct tm const* date);
41  wchar_t* dest, struct tm const* time);
46 
47 #ifdef __cplusplus
48 } // extern "C"
49 
50 namespace XsTime
51 {
52 /*! \brief The number of seconds in a day */
53 static const XsTimeStamp& secPerDay = XsTime_secPerDay;
54 /*! \brief The number of milliseconds in a day */
55 static const XsTimeStamp& milliSecPerDay = XsTime_milliSecPerDay;
56 /*! \brief The maximum possible timestamp */
57 static const XsTimeStamp& timeStampMax = XsTime_timeStampMax;
58 
59 //! \copydoc XsTime_getTimeOfDay
60 inline uint32_t getTimeOfDay(tm* date_ = nullptr, time_t* secs_ = nullptr)
61 {
62  return XsTime_getTimeOfDay(date_, secs_);
63 }
64 
65 //! \copydoc XsTime_getDateTime
66 inline int64_t getDateTime(tm* date = 0) { return XsTime_getDateTime(date); }
67 //! \copydoc XsTime_getDateAsString
68 inline void getDateAsString(char* dest, tm const* date = 0)
69 {
70  XsTime_getDateAsString(dest, date);
71 }
72 
73 #if 0
74 //! \copydoc XsTime_getTimeAsString
75 inline void getTimeAsString(char* dest, tm const* date = 0)
76 {
77  XsTime_getTimeAsString(dest, date);
78 }
79 
80 /*! \brief Returns the date as a readable string
81  \param date to convert to string
82  \returns The date as a readable string
83  \sa XsTime_getDateAsWString
84 */
85 inline XsString getDateAsString(tm const* date = 0)
86 {
87  wchar_t wcharBuf[9];
88  XsTime_getDateAsWString(wcharBuf, date);
89  wcharBuf[8] = 0;
90  return XsString(wcharBuf);
91 }
92 #endif
93 
94 /*! \brief Returns the time as a readable string
95  \param time to convert to string
96  \returns The time as a readable string
97  \sa XsTime_getTimeAsWString
98 */
99 inline XsString getTimeAsString(tm const* time = 0)
100 {
101  wchar_t wcharBuf[9];
102  XsTime_getTimeAsWString(wcharBuf, time);
103  wcharBuf[8] = 0;
104  return XsString(wcharBuf);
105 }
106 
107 //! \copydoc XsTime_msleep
108 inline void msleep(uint32_t ms) { XsTime_msleep(ms); }
109 //! \copydoc XsTime_udelay
110 inline void udelay(uint32_t us) { XsTime_udelay(us); }
111 //! \copydoc XsTime_initializeTime
112 inline void initializeTime() { XsTime_initializeTime(); }
113 //! \copydoc XsTime_timeStampNow
114 inline int64_t timeStampNow(XsTimeStamp* now = 0)
115 {
116  return XsTime_timeStampNow(now);
117 }
118 } // namespace XsTime
119 #endif
120 
121 #endif // file guard
XSTYPES_DLL_API const XsTimeStamp XsTime_milliSecPerDay
XSTYPES_DLL_API void XsTime_msleep(uint32_t ms)
mrpt::system::TTimeStamp now()
A shortcut for system::getCurrentTime.
Definition: datetime.h:86
TimeStamp timeStampNow(void)
Definition: xsens_time.cpp:101
XSTYPES_DLL_API uint32_t XsTime_getTimeOfDay(struct tm *date_, time_t *secs_)
XSTYPES_DLL_API void XsTime_udelay(uint32_t us)
void msleep(uint32_t ms)
A platform-independent sleep routine.
Definition: xsens_time.cpp:82
__int64 int64_t
Definition: rptypes.h:52
XSTYPES_DLL_API void XsTime_getTimeAsWString(wchar_t *dest, struct tm const *time)
Class for managing timestamps in a unified way.
Definition: xstimestamp.h:56
XSTYPES_DLL_API void XsTime_initializeTime(void)
XSTYPES_DLL_API void XsTime_getDateAsString(char *dest, struct tm const *date)
#define XSTYPES_DLL_API
Definition: xstypesconfig.h:9
XSTYPES_DLL_API int64_t XsTime_getDateTime(struct tm *date)
XSTYPES_DLL_API const XsTimeStamp XsTime_timeStampMax
XSTYPES_DLL_API const XsTimeStamp XsTime_secPerDay
XSTYPES_DLL_API int64_t XsTime_timeStampNow(XsTimeStamp *now)
struct XsString XsString
Definition: xsstring.h:35
unsigned __int32 uint32_t
Definition: rptypes.h:50
uint32_t getTimeOfDay(tm *date_, time_t *secs_)
A platform-independent clock.
Definition: xsens_time.cpp:34



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 8fe78517f Sun Jul 14 19:43:28 2019 +0200 at lun oct 28 02:10:00 CET 2019