【发布时间】:2011-08-22 04:45:53
【问题描述】:
目前我必须使用类似的东西
ptime t = from_time_t(last_write_time(p));
std::string Created = boost::posix_time::to_iso_extended_string(t) ;
或:
ptime t = from_time_t(last_write_time(p));
std::ostringstream formatter;
formatter.imbue(std::locale(std::cout.getloc(), new boost::posix_time::time_facet("%a, %d %b %Y %H:%M:%S GMT")));
formatter << t;
std::string Created = formatter.str();
首先速度很快,但与浏览器想要的标头时间格式不兼容,其次太慢了。所以我想知道 - 如何创建快速而有效的 ptime 到字符串格式化程序,它将 ptime 转换为 "%a, %d %b %Y %H:%M:%S GMT" 格式并且不会使用 ostringstream 和 .str() (因为它们对于我的目的来说太慢了)?
【问题讨论】:
-
嘿,我遇到了同样的问题,我看到你检查了这个答案是正确的,但我似乎无法理解你是如何使用它的。您将什么传递给 sprintf 以获取写入值?
标签: c++ boost formatting string-formatting boost-date-time