我使用的检索使用boost::posix_time
包含当前时间的字符串下面的方法:的boost ::了posix_time:检索时间和夏令时间
wstring TimeField::getActualTime() const {
// Defined elsewhere
auto m_facet = new new boost::posix_time::wtime_facet(L"%Y%m%d-%H:%M:%f");
std::locale m_locale(std::wcout.getloc(), m_facet);
// method body
std::basic_stringstream<wchar_t> wss;
wss.imbue(m_locale);
boost::posix_time::ptime now = boost::posix_time::microsec_clock::universal_time();
wss << now;
return wss.str();
}
我得到以下结果:
20161227-22:52:238902
,而在我的电脑的时间是23:52 。在我的PC(Windows 10)中有选项自动调整夏令时已激活。
有没有办法检索PC时间(并根据方面进行格式化),同时考虑到夏令时选项?
夏令时间目前并未生效。您可能需要解决不同的问题。 –