diff --git a/backends/twitter/TwitterResponseParser.cpp b/backends/twitter/TwitterResponseParser.cpp index b908b770e445ea074eac569159a94729af28d3e9..b8a4d18cf905ddd2fb4acca637cd6ee54f64767e 100644 --- a/backends/twitter/TwitterResponseParser.cpp +++ b/backends/twitter/TwitterResponseParser.cpp @@ -2,6 +2,8 @@ #include "transport/logging.h" #include "boost/algorithm/string.hpp" #include +#include "boost/date_time/local_time/local_time.hpp" +#include "boost/date_time/time_facet.hpp" DEFINE_LOGGER(logger, "TwitterResponseParser") @@ -23,12 +25,17 @@ static std::string unescape(std::string data) { } static std::string toIsoTime(std::string in) { - time_t now = time(0); - struct tm *mtime = gmtime(&now); - strptime(in.c_str(), "%a %b %d %H:%M:%S %z %Y", mtime); - char buf[80]; - strftime(buf, sizeof(buf), "%Y%m%dT%H%M%S", mtime); - return buf; + std::locale locale(std::locale::classic(), new boost::local_time::local_time_input_facet("%a %b %d %H:%M:%S +0000 %Y")); + boost::local_time::local_time_facet* output_facet = new boost::local_time::local_time_facet(); + boost::local_time::local_date_time ldt(boost::local_time::not_a_date_time); + std::stringstream ss(in); + ss.imbue(locale); + ss.imbue(std::locale(ss.getloc(), output_facet)); + output_facet->format("%Y%m%dT%H%M%S"); // boost::local_time::local_time_facet::iso_time_format_specifier ? + ss >> ldt; + ss.str(""); + ss << ldt; + return ss.str(); } EmbeddedStatus getEmbeddedStatus(const Swift::ParserElement::ref &element, const std::string xmlns)