1
나는 boost :: posix_time :: ptime thorugh를주는 장치가 있습니다. 다른 데이터와 동기화하려면 NTP 타임 스탬프로 시간이 필요하며 NTP 초 및 NTP fract_seconds로 구분됩니다.부스트 :: posix_time :: ptime을 NTP 타임 스탬프로 변환
#include "boost/date_time/posix_time/posix_time.hpp"
#include <iostream>
using namespace std;
using boost::posix_time::ptime;
using boost::posix_time::time_duration;
using boost::gregorian::date;
int main()
{
ptime t = boost::posix_time::microsec_clock::local_time();
ptime myEpoch(date(1900,boost::gregorian::Jan,1));
time_duration myTimeFromEpoch = t - myEpoch;
boost::uint64_t myTimeAsInt = myTimeFromEpoch.ticks();
cout << myTimeAsInt << endl;
boost::uint32_t seconds = (boost::uint32_t)((myTimeAsInt >> 32) & 0xFFFFFFFF);
boost::uint32_t fraction = (boost::uint32_t)(myTimeAsInt & 0xFFFFFFFF);
cout << seconds << endl;
cout << fraction << endl;
return 0;
}
그러나 그것은 나에게주지 않는 올바른 결과 :
내가 좋아하는 뭔가를 시도? 어떤 도움을 주셔서 감사합니다.
@person이 투표를 끝내기 위해 'time_t'이 (가) NTP와 다른 것을 확인하지 못했습니다. – Nim