MRPT  1.9.9
xstime.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2018, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://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 #endif
25 
29 
30 XSTYPES_DLL_API uint32_t XsTime_getTimeOfDay(struct tm* date_, time_t* secs_);
32 XSTYPES_DLL_API void XsTime_getDateAsString(char* dest, struct tm const* date);
33 // XSTYPES_DLL_API void XsTime_getTimeAsString(char* dest, struct tm const*
34 // time);
35 // XSTYPES_DLL_API void XsTime_getDateAsWString(
36 // wchar_t* dest, struct tm const* date);
38  wchar_t* dest, struct tm const* time);
43 
44 #ifdef __cplusplus
45 } // extern "C"
46 
47 namespace XsTime
48 {
49 /*! \brief The number of seconds in a day */
50 static const XsTimeStamp& secPerDay = XsTime_secPerDay;
51 /*! \brief The number of milliseconds in a day */
52 static const XsTimeStamp& milliSecPerDay = XsTime_milliSecPerDay;
53 /*! \brief The maximum possible timestamp */
54 static const XsTimeStamp& timeStampMax = XsTime_timeStampMax;
55 
56 //! \copydoc XsTime_getTimeOfDay
57 inline uint32_t getTimeOfDay(tm* date_ = nullptr, time_t* secs_ = nullptr)
58 {
59  return XsTime_getTimeOfDay(date_, secs_);
60 }
61 
62 //! \copydoc XsTime_getDateTime
63 inline int64_t getDateTime(tm* date = 0) { return XsTime_getDateTime(date); }
64 //! \copydoc XsTime_getDateAsString
65 inline void getDateAsString(char* dest, tm const* date = 0)
66 {
67  XsTime_getDateAsString(dest, date);
68 }
69 
70 #if 0
71 //! \copydoc XsTime_getTimeAsString
72 inline void getTimeAsString(char* dest, tm const* date = 0)
73 {
74  XsTime_getTimeAsString(dest, date);
75 }
76 
77 /*! \brief Returns the date as a readable string
78  \param date to convert to string
79  \returns The date as a readable string
80  \sa XsTime_getDateAsWString
81 */
82 inline XsString getDateAsString(tm const* date = 0)
83 {
84  wchar_t wcharBuf[9];
85  XsTime_getDateAsWString(wcharBuf, date);
86  wcharBuf[8] = 0;
87  return XsString(wcharBuf);
88 }
89 #endif
90 
91 /*! \brief Returns the time as a readable string
92  \param time to convert to string
93  \returns The time as a readable string
94  \sa XsTime_getTimeAsWString
95 */
96 inline XsString getTimeAsString(tm const* time = 0)
97 {
98  wchar_t wcharBuf[9];
99  XsTime_getTimeAsWString(wcharBuf, time);
100  wcharBuf[8] = 0;
101  return XsString(wcharBuf);
102 }
103 
104 //! \copydoc XsTime_msleep
105 inline void msleep(uint32_t ms) { XsTime_msleep(ms); }
106 //! \copydoc XsTime_udelay
107 inline void udelay(uint32_t us) { XsTime_udelay(us); }
108 //! \copydoc XsTime_initializeTime
109 inline void initializeTime() { XsTime_initializeTime(); }
110 //! \copydoc XsTime_timeStampNow
111 inline int64_t timeStampNow(XsTimeStamp* now = 0)
112 {
113  return XsTime_timeStampNow(now);
114 }
115 }
116 #endif
117 
118 #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:87
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:49
XSTYPES_DLL_API void XsTime_getTimeAsWString(wchar_t *dest, struct tm const *time)
Class for managing timestamps in a unified way.
Definition: xstimestamp.h:53
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:34
unsigned __int32 uint32_t
Definition: rptypes.h:47
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: 7d5e6d718 Fri Aug 24 01:51:28 2018 +0200 at lun nov 2 08:35:50 CET 2020