【发布时间】:2020-09-18 10:03:53
【问题描述】:
有没有办法只从 Poco 获取 Date ?一种方法是获取 Poco DateTime 标记并截断日期,但是有什么方法可以直接给出当前日期? 比如我用这样的方法来获取日期
void getTimestamp(std::string &out_iTimestamp)
{
//Get the CurrentTimestamp
Poco::Timestamp t_oCurTimestamp;
Poco::DateTimeFormatter t_oFormatter;
string t_strDateTime;
t_oFormatter.append(t_strDateTime, t_oCurTimestamp, Poco::DateTimeFormat::ISO8601_FORMAT);
out_iTimestamp = t_strDateTime;
} 现在我正在截断日期
std::string t_strDateTime;
std::string t_strDate;
getTimestamp(t_strDateTime);
//extract the only Date from DateTimeStamp
std::size_t found = t_strDateTime.find('T');
if (found != std::string::npos){
t_strDate = t_strDateTime.substr(0,found);
}
有人知道简单的方法吗?
【问题讨论】:
标签: c++11 poco poco-libraries