27 #include "../TimePoint.h"
28 #include "../BoostDurationCast.h"
29 #pragma GCC diagnostic push
30 #pragma GCC diagnostic ignored "-Wall"
31 #pragma GCC diagnostic ignored "-Wpragmas"
32 #pragma GCC diagnostic ignored "-Wunused-parameter"
33 #pragma GCC diagnostic ignored "-Wunused-variable"
34 #include <boost/units/quantity.hpp>
35 #include <boost/units/conversion.hpp>
36 #include <boost/units/systems/si/time.hpp>
37 #pragma GCC diagnostic pop
42 namespace astrotypes {
45 template<
typename ClockType,
typename Duration>
47 :
std::chrono::time_point<ClockType, Duration>(d)
51 template<
typename ClockType,
typename Duration>
52 template<
typename QuantityType>
54 boost::units::is_quantity<QuantityType>::value
55 && boost::units::is_unit_of_dimension<typename QuantityType::unit_type, boost::units::time_dimension>::value
56 , QuantityType>::type)
57 :
std::chrono::time_point<ClockType, Duration>(
duration_cast<typename ClockType::duration>(d))
61 template<
typename ClockType,
typename Duration>
63 :
std::chrono::time_point<ClockType, Duration>(
std::chrono::
duration_cast<typename ClockType::duration>(tp.time_since_epoch()) + ClockType::diff_from_system_epoch)
67 template<
typename ClockType,
typename Duration>
69 :
std::chrono::time_point<ClockType, Duration>(tp)
73 template<
typename ClockType,
typename Duration>
75 :
std::chrono::time_point<ClockType, Duration>(
std::move(tp))
79 template<
typename ClockType,
typename Duration>
82 auto dur = this->time_since_epoch() - ClockType::diff_from_system_epoch;
83 return std::chrono::system_clock::time_point(std::chrono::duration_cast<std::chrono::system_clock::duration>(dur));
86 template<
typename ClockType,
typename Duration>
89 return std::chrono::system_clock::to_time_t(static_cast<std::chrono::system_clock::time_point>(*
this));
92 template<
typename ClockType,
typename Duration>
93 std::ostream& operator<<(std::ostream& os, TimePoint<ClockType, Duration>
const& tp)
98 os << tp.time_since_epoch().count() <<
" " << ClockType::symbol;
102 template<
typename ClockType,
typename Duration>
109 template<
typename ClockType,
typename Duration>
116 template<
typename ClockType,
typename Duration,
typename Duration2>
121 template<
typename ClockType,
typename DurationType,
typename Rep>
123 typedef typename ClockType::duration Duration;
127 template<
typename ClockType,
typename DurationType,
typename Rep>
130 typedef typename ClockType::duration Duration;
134 template<
typename ClockType,
typename DurationType,
typename Rep>
136 typedef typename ClockType::duration Duration;
140 template<
typename ClockType,
typename DurationType,
typename Rep>
143 typedef typename ClockType::duration Duration;
147 template<
typename ClockType,
typename Duration,
typename Duration2>
152 template<
typename ClockType,
typename Duration,
typename Duration2>
155 return static_cast<std::chrono::time_point<ClockType, Duration>
>(lhs) -
static_cast<std::chrono::time_point<ClockType, Duration2>
>(rhs);
TimePoint(const Duration &d=typename ClockType::duration())
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...
TimePoint< ClockType, Duration > operator+(TimePoint< ClockType, Duration > const &lhs, Duration2 const &rhs)
TimePoint< ClockType, DurationType > & operator-=(TimePoint< ClockType, DurationType > &lhs, boost::units::quantity< boost::units::si::time, Rep > const &rhs)
TimePoint< ClockType, Duration > & operator-=(Duration const &)
TimePoint< ClockType, Duration > & operator+=(Duration const &)
TimePoint< ClockType, DurationType > operator-(TimePoint< ClockType, DurationType > const &lhs, boost::units::quantity< boost::units::si::time, Rep > const &rhs)
constexpr std::enable_if< boost::units::is_quantity< BoostQuantity >::value &&boost::units::is_unit_of_dimension< typename BoostQuantity::unit_type, boost::units::time_dimension >::value &&!is_equivalent< BoostQuantity, std::chrono::duration< ChronoNumericalRep, PeriodType > >::value, BoostQuantity >::type duration_cast(const std::chrono::duration< ChronoNumericalRep, PeriodType > &duration)
Mimic the std::duration_cast to convert to/from boost::units::quantity
TimePoint< ClockType, DurationType > & operator+=(TimePoint< ClockType, DurationType > &lhs, boost::units::quantity< boost::units::si::time, Rep > const &rhs)
extension of std::chrono::time_point for astrotypes clocks