diff options
author | Andrej Rode <andrej.rode@ettus.com> | 2017-03-01 13:35:30 -0800 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2017-04-12 12:15:02 -0700 |
commit | 2ae347f12ed1ba42f65a800b6ebf3779ee3195c2 (patch) | |
tree | 055b95b888d57e8f00d7da49ff6a8cb57f736ee0 /host/lib/usrp | |
parent | 3634302ff3751bd27aba224e5f6ff51dffd813c3 (diff) | |
download | uhd-2ae347f12ed1ba42f65a800b6ebf3779ee3195c2.tar.gz uhd-2ae347f12ed1ba42f65a800b6ebf3779ee3195c2.tar.bz2 uhd-2ae347f12ed1ba42f65a800b6ebf3779ee3195c2.zip |
gps_ctrl: dont use gmtime
Diffstat (limited to 'host/lib/usrp')
-rw-r--r-- | host/lib/usrp/gps_ctrl.cpp | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/host/lib/usrp/gps_ctrl.cpp b/host/lib/usrp/gps_ctrl.cpp index 209ded29f..a5d1748fe 100644 --- a/host/lib/usrp/gps_ctrl.cpp +++ b/host/lib/usrp/gps_ctrl.cpp @@ -30,9 +30,7 @@ #include <boost/thread/mutex.hpp> #include <ctime> #include <string> -#if defined(WIN32) || defined(MINGW) -#define timegm _mkgmtime -#endif +#include <boost/date_time.hpp> #include "boost/tuple/tuple.hpp" @@ -351,18 +349,16 @@ private: throw uhd::value_error(str(boost::format("Invalid response \"%s\"") % reply)); } - time_t raw_time = std::time(nullptr); - struct tm *raw_date = std::gmtime(&raw_time); // Initialize tm struct - raw_date->tm_year = std::stoi(datestr.substr(4, 2)) + 2000 - 1900; // years since 1900 - raw_date->tm_mon = std::stoi(datestr.substr(2, 2)) - 1; // months since january (0-11) - raw_date->tm_mday = std::stoi(datestr.substr(0, 2)); // dom (1-31) - raw_date->tm_hour = std::stoi(timestr.substr(0, 2)); - raw_date->tm_min = std::stoi(timestr.substr(2, 2)); - raw_date->tm_sec = std::stoi(timestr.substr(4,2)); - std::time_t gps_date = timegm(raw_date); // GPS time is UTC - - gps_time = boost::posix_time::from_time_t(gps_date); + struct tm raw_date; + raw_date.tm_year = std::stoi(datestr.substr(4, 2)) + 2000 - 1900; // years since 1900 + raw_date.tm_mon = std::stoi(datestr.substr(2, 2)) - 1; // months since january (0-11) + raw_date.tm_mday = std::stoi(datestr.substr(0, 2)); // dom (1-31) + raw_date.tm_hour = std::stoi(timestr.substr(0, 2)); + raw_date.tm_min = std::stoi(timestr.substr(2, 2)); + raw_date.tm_sec = std::stoi(timestr.substr(4,2)); + gps_time = boost::posix_time::ptime_from_tm(raw_date); + UHD_LOG_TRACE("GPS", "GPS time: " + boost::posix_time::to_simple_string(gps_time)); return gps_time; } catch(std::exception &e) { |