xstime.h
Go to the documentation of this file.
1 
2 // Copyright (c) 2003-2021 Xsens Technologies B.V. or subsidiaries worldwide.
3 // All rights reserved.
4 //
5 // Redistribution and use in source and binary forms, with or without modification,
6 // are permitted provided that the following conditions are met:
7 //
8 // 1. Redistributions of source code must retain the above copyright notice,
9 // this list of conditions, and the following disclaimer.
10 //
11 // 2. Redistributions in binary form must reproduce the above copyright notice,
12 // this list of conditions, and the following disclaimer in the documentation
13 // and/or other materials provided with the distribution.
14 //
15 // 3. Neither the names of the copyright holders nor the names of their contributors
16 // may be used to endorse or promote products derived from this software without
17 // specific prior written permission.
18 //
19 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
20 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
22 // THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 // SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
24 // OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY OR
26 // TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.THE LAWS OF THE NETHERLANDS
28 // SHALL BE EXCLUSIVELY APPLICABLE AND ANY DISPUTES SHALL BE FINALLY SETTLED UNDER THE RULES
29 // OF ARBITRATION OF THE INTERNATIONAL CHAMBER OF COMMERCE IN THE HAGUE BY ONE OR MORE
30 // ARBITRATORS APPOINTED IN ACCORDANCE WITH SAID RULES.
31 //
32 
33 
34 // Copyright (c) 2003-2021 Xsens Technologies B.V. or subsidiaries worldwide.
35 // All rights reserved.
36 //
37 // Redistribution and use in source and binary forms, with or without modification,
38 // are permitted provided that the following conditions are met:
39 //
40 // 1. Redistributions of source code must retain the above copyright notice,
41 // this list of conditions, and the following disclaimer.
42 //
43 // 2. Redistributions in binary form must reproduce the above copyright notice,
44 // this list of conditions, and the following disclaimer in the documentation
45 // and/or other materials provided with the distribution.
46 //
47 // 3. Neither the names of the copyright holders nor the names of their contributors
48 // may be used to endorse or promote products derived from this software without
49 // specific prior written permission.
50 //
51 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
52 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
53 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
54 // THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
55 // SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
56 // OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
57 // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY OR
58 // TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
59 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.THE LAWS OF THE NETHERLANDS
60 // SHALL BE EXCLUSIVELY APPLICABLE AND ANY DISPUTES SHALL BE FINALLY SETTLED UNDER THE RULES
61 // OF ARBITRATION OF THE INTERNATIONAL CHAMBER OF COMMERCE IN THE HAGUE BY ONE OR MORE
62 // ARBITRATORS APPOINTED IN ACCORDANCE WITH SAID RULES.
63 //
64 
65 #ifndef XSTIME_H
66 #define XSTIME_H
67 
68 #include "xstypesconfig.h"
69 #ifdef _WIN32
70  #include <windows.h>
71 #endif
72 
73 #include <time.h>
74 #include "pstdint.h"
75 #include "xstimestamp.h"
76 
77 #ifdef __cplusplus
78 #include "xsstring.h"
79 extern "C" {
80 #endif
81 
85 
86 XSTYPES_DLL_API uint32_t XsTime_getTimeOfDay(struct tm* date_, time_t* secs_);
87 XSTYPES_DLL_API int64_t XsTime_getDateTime(struct tm* date);
88 XSTYPES_DLL_API void XsTime_getDateAsString(char* dest, struct tm const* date);
89 XSTYPES_DLL_API void XsTime_getTimeAsString(char* dest, struct tm const* time);
90 XSTYPES_DLL_API void XsTime_getDateAsWString(wchar_t* dest, struct tm const* date);
91 XSTYPES_DLL_API void XsTime_getTimeAsWString(wchar_t* dest, struct tm const* time);
93 XSTYPES_DLL_API void XsTime_udelay(uint64_t us);
98 
99 #ifdef __cplusplus
100 } // extern "C"
101 
102 namespace XsTime
103 {
104 #ifdef __GNUC__
105  #pragma GCC diagnostic push
106  #pragma GCC diagnostic ignored "-Wunused-variable"
107 #endif
108 
109 static const XsTimeStamp& secPerDay = XsTime_secPerDay;
111 static const XsTimeStamp& milliSecPerDay = XsTime_milliSecPerDay;
113 static const XsTimeStamp& timeStampMax = XsTime_timeStampMax;
114 #ifdef __GNUC__
115  #pragma GCC diagnostic pop
116 #endif
117 
119 inline uint32_t getTimeOfDay(tm* date_ = NULL, time_t* secs_ = NULL)
120 {
121  return XsTime_getTimeOfDay(date_, secs_);
122 }
123 
125 inline int64_t getDateTime(tm* date = 0)
126 {
127  return XsTime_getDateTime(date);
128 }
129 
131 inline void getDateAsString(char* dest, tm const* date = 0)
132 {
133  XsTime_getDateAsString(dest, date);
134 }
135 
137 inline void getTimeAsString(char* dest, tm const* date = 0)
138 {
139  XsTime_getTimeAsString(dest, date);
140 }
141 
147 inline XsString getDateAsString(tm const* date = 0)
148 {
149  wchar_t wcharBuf[9];
150  XsTime_getDateAsWString(wcharBuf, date);
151  wcharBuf[8] = 0;
152  return XsString(wcharBuf);
153 }
154 
160 inline XsString getTimeAsString(tm const* time = 0)
161 {
162  wchar_t wcharBuf[9];
163  XsTime_getTimeAsWString(wcharBuf, time);
164  wcharBuf[8] = 0;
165  return XsString(wcharBuf);
166 }
167 
169 inline void msleep(uint32_t ms) noexcept
170 {
171  XsTime_msleep(ms);
172 }
173 
175 inline void udelay(uint64_t us) noexcept
176 {
177  XsTime_udelay(us);
178 }
179 
181 inline void initializeTime()
182 {
184 }
185 
187 inline int64_t timeStampNow(XsTimeStamp* now = 0)
188 {
189  return XsTime_timeStampNow(now);
190 }
191 }
192 #endif
193 
194 #endif
XsTime_initializeTime
XSTYPES_DLL_API void XsTime_initializeTime(void)
Stabilize the clock.
Definition: xstime.c:424
XsString
struct XsString XsString
Definition: xsstring.h:87
xsstring.h
XsTime_udelay
XSTYPES_DLL_API void XsTime_udelay(uint64_t us)
Delays the current thread for at least us microseconds.
Definition: xstime.c:369
XsTime_milliSecPerDay
const XSTYPES_DLL_API XsTimeStamp XsTime_milliSecPerDay
The number of milliseconds in a normal day.
Definition: xstime.c:91
XsTime_msleep
XSTYPES_DLL_API void XsTime_msleep(uint32_t ms)
Make the current thread sleep for at least ms milliseconds.
Definition: xstime.c:353
time.h
xstimestamp.h
XsTime_getTimeOfDay
XSTYPES_DLL_API uint32_t XsTime_getTimeOfDay(struct tm *date_, time_t *secs_)
The function returns the current time of day in ms since midnight.
Definition: xstime.c:134
XsTime_secPerDay
const XSTYPES_DLL_API XsTimeStamp XsTime_secPerDay
The number of seconds in a normal day.
Definition: xstime.c:88
XsTime
Namespace for time and date constants and operations.
XsTime_getDateTime
XSTYPES_DLL_API int64_t XsTime_getDateTime(struct tm *date)
Retrieves the date and time (platform-independent)
Definition: xstime.c:234
XsTime_localToUtc
XSTYPES_DLL_API int64_t XsTime_localToUtc()
Returns the conversion value from local time to UTC time in ms.
Definition: xstime.c:468
uint32_t
unsigned int uint32_t
Definition: pstdint.h:485
XsTime_getTimeAsWString
XSTYPES_DLL_API void XsTime_getTimeAsWString(wchar_t *dest, struct tm const *time)
Retrieves the time as binary The format is HHMMSShh (where H is hour and 'h' is hundredths) so 14:25:...
Definition: xstime.c:334
XsTime_getTimeAsString
XSTYPES_DLL_API void XsTime_getTimeAsString(char *dest, struct tm const *time)
Retrieves the time as binary The format is HHMMSShh (where H is hour and 'h' is hundredths) so 14:25:...
Definition: xstime.c:292
XsTime_getDateAsWString
XSTYPES_DLL_API void XsTime_getDateAsWString(wchar_t *dest, struct tm const *date)
Retrieves the date as wstring representation The format is YYYYMMDD so 25 dec 2010 is stored as an ar...
Definition: xstime.c:312
XsTime_getDateAsString
XSTYPES_DLL_API void XsTime_getDateAsString(char *dest, struct tm const *date)
Retrieves the date as string representation The format is YYYYMMDD so 25 dec 2010 is stored as an arr...
Definition: xstime.c:260
xstypesconfig.h
pstdint.h
XsTime_timeStampNow
XSTYPES_DLL_API int64_t XsTime_timeStampNow(XsTimeStamp *now)
Returns the current time in ms since the epoch (Jan 1st 1970)
Definition: xstime.c:401
XSTYPES_DLL_API
#define XSTYPES_DLL_API
Definition: xstypesconfig.h:65
XsTime_utcToLocal
XSTYPES_DLL_API int64_t XsTime_utcToLocal()
Returns the conversion value from UTC time to local time in ms.
Definition: xstime.c:459
XsString
A 0-terminated managed string of characters.
XsTime_timeStampMax
const XSTYPES_DLL_API XsTimeStamp XsTime_timeStampMax
The maximum positive value of an XsTimeStamp value.
Definition: xstime.c:94
XsTimeStamp
This class contains method to set, retrieve and compare timestamps.
Definition: xstimestamp.h:115


xsens_mti_driver
Author(s):
autogenerated on Sun Sep 3 2023 02:43:20