現在の時刻からエポック秒と小数秒を提供する単純なタイムスタンプシステムを作成しようとしています。私はブーストライブラリを使用していて、次のようなものがあります:
const boost::posix_time::ptime epoch(boost::gregorian::date(1970, 1, 1));
boost::posix_time::ptime time() {
boost::posix_time::ptime now = boost::posix_time::microsec_clock::universal_time();
return now;
}
boost::posix_time::time_duration dur = (time() - epoch);
次に、次の要素を使用してエポック値を抽出します。
dur.total_seconds();
dur.fractional_seconds();
具体的には、これは適切なUNIX時間を返しますか?そうでない場合、それを修正する方法に関する提案はありますか?ありがとう。