utils.h
Go to the documentation of this file.
1 #ifndef UBLOX_GPS_UTILS_H
2 #define UBLOX_GPS_UTILS_H
3 
4 #include <math.h>
5 #include <time.h>
6 #include "ublox_msgs/NavPVT.h"
7 
8 extern "C" {
9  #include "ublox_gps/mkgmtime.h"
10 }
11 
15 template<typename NavPVT>
16 long toUtcSeconds(const NavPVT& msg) {
17  // Create TM struct for mkgmtime
18  struct tm time = {0};
19  time.tm_year = msg.year - 1900;
20  time.tm_mon = msg.month - 1;
21  time.tm_mday = msg.day;
22  time.tm_hour = msg.hour;
23  time.tm_min = msg.min;
24  time.tm_sec = msg.sec;
25  // C++ STL doesn't have a mkgmtime (though other libraries do)
26  // STL mktime converts date/time to seconds in local time
27  // A modified version of code external library is used for mkgmtime
28  return mkgmtime(&time);
29 }
30 
31 #endif
long toUtcSeconds(const NavPVT &msg)
Convert date/time to UTC time in seconds.
Definition: utils.h:16
time_t mkgmtime(struct tm *const tmp)
Get the UTC time in seconds and nano-seconds from a time struct in GM time.
Definition: mkgmtime.c:108


ublox_gps
Author(s): Johannes Meyer
autogenerated on Thu Jan 28 2021 03:13:52