1
任何想法为什么这是返回非日期时间,而不是时间字符串?我在Ubuntu 15.04使用升压1.55.0.2boost posix_time:stringstream输入失败
#include <iostream>
#include "boost/date_time/posix_time/posix_time.hpp"
using namespace boost::posix_time;
int main(int argc, char **argv) {
ptime t2;
std::stringstream ss("2004-Jan-1 05:21:33.20");
ss >> t2;
std::cout<<t2<< std::endl;
return 0;
}
正确,谢谢。我从boost文档中直接拉出该字符串,所以没有打扰检查。 http://www.boost.org/doc/libs/1_55_0/doc/html/date_time/examples/general_usage_examples.html – dmagree
某处是否有可接受的格式列表? posix时间文档不清楚。例如,它看起来像YYYY-MM-DD HH:MM:SS.fffffffff也可以接受给定的例子,但它也不适用于我。 – dmagree
我认为三个to_string转换格式是可以接受的,非常简单,iso和iso_extended。因此'YYYY-MM-DD HH:MM:SS.fffffffff'不会被接受,但是'YYYY-MM-DDTHH:MM:SS,fffffffff'会。 – slaphappy