From 2ae347f12ed1ba42f65a800b6ebf3779ee3195c2 Mon Sep 17 00:00:00 2001 From: Andrej Rode Date: Wed, 1 Mar 2017 13:35:30 -0800 Subject: gps_ctrl: dont use gmtime --- host/lib/usrp/gps_ctrl.cpp | 24 ++++++++++-------------- 1 file 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 #include #include -#if defined(WIN32) || defined(MINGW) -#define timegm _mkgmtime -#endif +#include #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) { -- cgit v1.2.3