【发布时间】:2018-08-07 05:17:55
【问题描述】:
我正在尝试解决以下代码的错误,在该错误中,我与 boost last_write_time 有一个小时的差异。
为了更好地解释它:我创建一个文件,然后尝试使用 boost::filesystem::path 提取它的创建时间。
void PrintTime(boost::filesystem::path _file) {
time_t sys_time{ last_write_time(_file) };
ptime p_time{ boost::posix_time::from_time_t(sys_time) };
boost::posix_time::time_duration time_dur{ p_time.time_of_day() };
long h{ time_dur.hours() }; //1a
long m{ time_dur.minutes() };
long s{ time_dur.seconds() };
//...print h, m, s.
}
//1a: Here when for example the time I expect is 12:34:56,
//I always get 11:34:56
知道为什么吗? boost last_write_time 中是否有时区? 当我通过系统检查文件时,我的操作系统显示正确的时间。
【问题讨论】:
标签: boost time boost-filesystem