From 61c428b82b462daeb9bec27cdd9c5bf97094cba0 Mon Sep 17 00:00:00 2001 From: Marina Ganeva <m.ganeva@fz-juelich.de> Date: Wed, 4 Apr 2018 13:58:30 +0200 Subject: [PATCH] Refs #21293 LoadDNSSCD: replace std::get_time with poco for rhel7 --- Framework/MDAlgorithms/src/LoadDNSSCD.cpp | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/Framework/MDAlgorithms/src/LoadDNSSCD.cpp b/Framework/MDAlgorithms/src/LoadDNSSCD.cpp index 0bbf2d2a274..8206ee2b6f3 100644 --- a/Framework/MDAlgorithms/src/LoadDNSSCD.cpp +++ b/Framework/MDAlgorithms/src/LoadDNSSCD.cpp @@ -4,9 +4,11 @@ #include <iomanip> #include <boost/date_time/posix_time/posix_time.hpp> #include <boost/regex.hpp> +#include <Poco/DateTime.h> #include <Poco/DateTimeFormat.h> #include <Poco/DateTimeFormatter.h> #include <Poco/DirectoryIterator.h> +#include <Poco/DateTimeParser.h> #include <Poco/Path.h> #include <Poco/File.h> #include "MantidMDAlgorithms/LoadDNSSCD.h" @@ -64,20 +66,14 @@ std::string parseTime(std::string &str) { auto time = time_from_string(str); return to_iso_extended_string(time); } catch (std::exception &) { - // if time is not in posix format - // change all sindle-digit days to 0d (otherwise get_time does not parse) - boost::regex expr("\\s+([0-9]\\s+)"); - std::string fmt{" 0\\1"}; - str = boost::regex_replace(str, expr, fmt); - std::istringstream ss(str); - 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); + int tzd; + Poco::DateTime dt; + bool ok = Poco::DateTimeParser::tryParse(str, dt, tzd); + if (ok) { + auto time = Poco::DateTimeFormatter::format(dt, "%Y-%m-%dT%H:%M:%S"); + return time; } - + std::string result(""); return result; } } -- GitLab