24 #include "cheetah/utils/detail/TimePoint.h" 25 #pragma GCC diagnostic push 26 #pragma GCC diagnostic ignored "-Wall" 27 #pragma GCC diagnostic ignored "-Wpragmas" 28 #pragma GCC diagnostic ignored "-Wunused-parameter" 29 #pragma GCC diagnostic ignored "-Wunused-variable" 30 #include <boost/units/quantity.hpp> 31 #include <boost/units/conversion.hpp> 32 #include <boost/units/systems/si/time.hpp> 33 #pragma GCC diagnostic pop 41 template<
typename ClockType,
typename Duration>
42 TimePoint<ClockType, Duration>::TimePoint(
const Duration& d )
43 :
std::chrono::time_point<ClockType, Duration>(d)
47 template<
typename ClockType,
typename Duration>
48 TimePoint<ClockType, Duration>::TimePoint(
const std::chrono::system_clock::time_point& tp )
49 :
std::chrono::time_point<ClockType, Duration>(
std::chrono::duration_cast<typename ClockType::duration>(tp.time_since_epoch()) + ClockType::diff_from_system_epoch)
53 template<
typename ClockType,
typename Duration>
54 TimePoint<ClockType, Duration>::TimePoint(
const std::chrono::time_point<ClockType, Duration>& tp )
55 :
std::chrono::time_point<ClockType, Duration>(tp)
59 template<
typename ClockType,
typename Duration>
60 TimePoint<ClockType, Duration>::TimePoint( std::chrono::time_point<ClockType, Duration>&& tp )
61 :
std::chrono::time_point<ClockType, Duration>(
std::move(tp))
65 template<
typename ClockType,
typename Duration>
66 TimePoint<ClockType, Duration>::operator
typename std::chrono::system_clock::time_point()
const 68 auto dur = this->time_since_epoch() - ClockType::diff_from_system_epoch;
69 return std::chrono::system_clock::time_point(std::chrono::duration_cast<std::chrono::system_clock::duration>(dur));
72 template<
typename ClockType,
typename Duration>
75 return std::chrono::system_clock::to_time_t(static_cast<std::chrono::system_clock::time_point>(*
this));
78 template<
typename ClockType,
typename Duration>
79 std::ostream& operator<<(std::ostream& os, TimePoint<ClockType, Duration>
const& tp)
84 os << tp.time_since_epoch().count() <<
" " << ClockType::symbol;
88 template<
typename ClockType,
typename Duration>
91 std::chrono::time_point<ClockType, Duration>::operator+=(d);
95 template<
typename ClockType,
typename Duration>
98 std::chrono::time_point<ClockType, Duration>::operator-=(d);
102 template<
typename ClockType,
typename Duration,
typename Duration2>
107 template<
typename ClockType,
typename DurationType,
typename Rep>
109 typedef typename ClockType::duration Duration;
110 return lhs + Duration(boost::units::quantity_cast<typename Duration::rep>(rhs));
113 template<
typename ClockType,
typename Duration,
typename Duration2>
118 template<
typename ClockType,
typename Duration,
typename Duration2>
121 return static_cast<std::chrono::time_point<ClockType, Duration>
>(lhs) -
static_cast<std::chrono::time_point<ClockType, Duration2>
>(rhs);
Some limits and constants for FLDO.
std::time_t to_time_t() const
convert to a C style time struct. very useful if you want to output the time as a string with e...
extension of std::chrono::time_point for chhetah clocks