Skip to content
Snippets Groups Projects
Commit 61c428b8 authored by Marina Ganeva's avatar Marina Ganeva
Browse files

Refs #21293 LoadDNSSCD: replace std::get_time with poco for rhel7

parent c535f59c
No related branches found
No related tags found
No related merge requests found
...@@ -4,9 +4,11 @@ ...@@ -4,9 +4,11 @@
#include <iomanip> #include <iomanip>
#include <boost/date_time/posix_time/posix_time.hpp> #include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/regex.hpp> #include <boost/regex.hpp>
#include <Poco/DateTime.h>
#include <Poco/DateTimeFormat.h> #include <Poco/DateTimeFormat.h>
#include <Poco/DateTimeFormatter.h> #include <Poco/DateTimeFormatter.h>
#include <Poco/DirectoryIterator.h> #include <Poco/DirectoryIterator.h>
#include <Poco/DateTimeParser.h>
#include <Poco/Path.h> #include <Poco/Path.h>
#include <Poco/File.h> #include <Poco/File.h>
#include "MantidMDAlgorithms/LoadDNSSCD.h" #include "MantidMDAlgorithms/LoadDNSSCD.h"
...@@ -64,20 +66,14 @@ std::string parseTime(std::string &str) { ...@@ -64,20 +66,14 @@ std::string parseTime(std::string &str) {
auto time = time_from_string(str); auto time = time_from_string(str);
return to_iso_extended_string(time); return to_iso_extended_string(time);
} catch (std::exception &) { } catch (std::exception &) {
// if time is not in posix format int tzd;
// change all sindle-digit days to 0d (otherwise get_time does not parse) Poco::DateTime dt;
boost::regex expr("\\s+([0-9]\\s+)"); bool ok = Poco::DateTimeParser::tryParse(str, dt, tzd);
std::string fmt{" 0\\1"}; if (ok) {
str = boost::regex_replace(str, expr, fmt); auto time = Poco::DateTimeFormatter::format(dt, "%Y-%m-%dT%H:%M:%S");
std::istringstream ss(str); return time;
std::tm t = {};
ss >> std::get_time(&t, "%a %b %d %H:%M:%S %Y");
std::string result("");
if (!ss.fail()) {
auto time = ptime_from_tm(t);
return to_iso_extended_string(time);
} }
std::string result("");
return result; return result;
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment