나는 SQL 서버 데이터베이스를 가지고 있고 그것에서 날짜를 당겨 같은 INT64에 timestamp_t의 종류를 변환하고 있습니다 :SQL Server에서 timestamp_t를 부스트하는 ptime이 분 단위로 해제됩니다. 나는 무엇을 잘못 했는가?
Int64 from_timestamp_t(dtl::timestamp_t& t)
{
// create a new posix time structure
boost::posix_time::ptime pt
(
boost::gregorian::date (t.year, t.month, t.day),
boost::posix_time::time_duration (t.hour, t.minute, t.second, t.fraction)
);
ptime epoch(date(1970, Jan, 1));
boost::posix_time::time_duration fromEpoch = pt - epoch;
// return it to caller
return fromEpoch.total_milliseconds();
}
나는 등의 INT64에서 부스트의 Ptime로 다시 변환하려고 시도 :
이유가 무엇인지, 내 날짜, 시간 등이 모두 정확한 이유는 알 수 없지만 내 분은 앞으로 몇 분이 걸릴 것입니다. 데이터베이스의 타임 스탬프가 초 단위이기 때문에 밀리 초를 사용하고 있습니까? 이 문제를 어떻게 해결할 수 있습니까?
Int64 from_timestamp_t(dtl::timestamp_t& t)
{
int count = t.fraction * (time_duration::ticks_per_second() % 1000);
boost::posix_time::ptime pt
(
boost::gregorian::date (t.year, t.month, t.day),
boost::posix_time::time_duration (t.hour, t.minute, t.second, count)
);
ptime epoch(date(1970, Jan, 1), time_duration(0, 0, 0, 0));
boost::posix_time::time_duration fromEpoch = pt - epoch;
return fromEpoch.total_milliseconds();
}
댄의 대답은 내가 찾을 – jjacksonRIAB