autoMatchReplyTime; if(自动计时pt; 标准::cout,c++,boost,boost-date-time,C++,Boost,Boost Date Time" /> autoMatchReplyTime; if(自动计时pt; 标准::cout,c++,boost,boost-date-time,C++,Boost,Boost Date Time" />

如何从日期输入方面创建Boost ptime对象 我尝试使用C++ Boost DATEYTIME库将一个格式为“16:43 2012年12月12日”的字符串加载到具有“%H:%M%B%D,%Y”的日期输入面的String流中。 接下来,我想从stringstream创建一个Boost ptime对象,以便进行日期/时间计算。 我无法让它工作–下面是代码: std::string autoMatchTimeStr(row["message_time"]); ptime autoMatchTime(time_from_string(autoMatchTimeStr)); date_input_facet* fin = new date_input_facet("%H:%M %B %d, %Y"); stringstream dtss; dtss.imbue(std::locale(std::locale::classic(), fin)); dtss << msg.getDate(); //msg.getDate() returns “16:43 December 12, 2012” ptime autoMatchReplyTime; dtss >> autoMatchReplyTime; if( autoMatchReplyTime < autoMatchTime + minutes(15)) { stats[ "RespTimeLow" ] = "increment"; sysLog << "RespTimeLow" << flush; } std::string autoMatchTimeStr(行[“消息时间]); ptime autoMatchTime(来自字符串的时间(autoMatchTimeStr)); 日期输入面*fin=新的日期输入面(“%H:%M%B%d,%Y”); stringstream dtss; imbue(std::locale(std::locale::classic(),fin)); dtss>autoMatchReplyTime; if(自动计时pt; 标准::cout

如何从日期输入方面创建Boost ptime对象 我尝试使用C++ Boost DATEYTIME库将一个格式为“16:43 2012年12月12日”的字符串加载到具有“%H:%M%B%D,%Y”的日期输入面的String流中。 接下来,我想从stringstream创建一个Boost ptime对象,以便进行日期/时间计算。 我无法让它工作–下面是代码: std::string autoMatchTimeStr(row["message_time"]); ptime autoMatchTime(time_from_string(autoMatchTimeStr)); date_input_facet* fin = new date_input_facet("%H:%M %B %d, %Y"); stringstream dtss; dtss.imbue(std::locale(std::locale::classic(), fin)); dtss << msg.getDate(); //msg.getDate() returns “16:43 December 12, 2012” ptime autoMatchReplyTime; dtss >> autoMatchReplyTime; if( autoMatchReplyTime < autoMatchTime + minutes(15)) { stats[ "RespTimeLow" ] = "increment"; sysLog << "RespTimeLow" << flush; } std::string autoMatchTimeStr(行[“消息时间]); ptime autoMatchTime(来自字符串的时间(autoMatchTimeStr)); 日期输入面*fin=新的日期输入面(“%H:%M%B%d,%Y”); stringstream dtss; imbue(std::locale(std::locale::classic(),fin)); dtss>autoMatchReplyTime; if(自动计时pt; 标准::cout,c++,boost,boost-date-time,C++,Boost,Boost Date Time,那么…为什么要尝试使用date\u input\u facet而不是time\u input\u facet #include <sstream> #include <boost/date_time/posix_time/posix_time.hpp> int main() { const std::string time = "16:43 December 12, 2012"; boost::posix_time::time_input_facet* fa

那么…为什么要尝试使用
date\u input\u facet
而不是
time\u input\u facet

#include <sstream>
#include <boost/date_time/posix_time/posix_time.hpp>

int main()
{
   const std::string time = "16:43 December 12, 2012";
   boost::posix_time::time_input_facet* facet =
   new boost::posix_time::time_input_facet("%H:%M %B %d, %Y");
   std::stringstream ss;
   ss.imbue(std::locale(std::locale(), facet));
   ss << time;
   boost::posix_time::ptime pt;
   ss >> pt;
   std::cout << pt << std::endl;
}
#包括
#包括
int main()
{
const std::string time=“2012年12月12日16:43”;
boost::posix_time::time_input_facet*facet=
新的boost::posix_time::time_input_facet(“%H:%M%B%d,%Y”);
std::stringstream-ss;
imbue(std::locale(std::locale(),facet));
ss>pt;
标准::cout