10 #ifndef INTERSTELLAR_HPP 11 #define INTERSTELLAR_HPP 14 #include <boost/date_time/posix_time/posix_time.hpp> 17 namespace duds {
namespace time {
namespace interstellar {
52 template <
class Clock,
class Duration>
53 class TimePoint :
public std::chrono::time_point<Clock, Duration> {
61 template <
class OtherRep,
class OtherPeriod>
62 constexpr
TimePoint(
const std::chrono::duration<OtherRep, OtherPeriod> &od) :
63 std::chrono::time_point<
Clock, Duration>(
64 std::chrono::duration_cast<Duration, typename Duration::rep, typename Duration::period>(od)
83 template <
class OtherClock,
class OtherDuration>
84 constexpr
TimePoint(
const std::chrono::time_point<OtherClock, OtherDuration> &otp) :
85 std::chrono::time_point<
Clock, Duration>(
86 std::chrono::duration_cast<Duration>(otp.time_since_epoch())
95 template <
class OtherClock,
class OtherDuration>
105 std::numeric_limits<typename Duration::rep>::lowest()
113 std::numeric_limits<typename Duration::rep>::max()
139 typedef duration::rep
rep;
142 static constexpr
bool is_steady =
false;
143 static time_point
now() noexcept {
144 return time_point(std::chrono::duration_cast<duration, rep, period>(
145 std::chrono::system_clock::now().time_since_epoch()));
180 typedef duration::rep
rep;
183 static constexpr
bool is_steady =
false;
184 static time_point
now() noexcept {
185 return time_point(std::chrono::duration_cast<duration>(
186 std::chrono::system_clock::now().time_since_epoch()));
207 typedef std::chrono::duration<std::uint64_t, std::nano>
Nanoseconds;
218 typedef duration::rep
rep;
221 static constexpr
bool is_steady =
false;
222 static time_point
now() noexcept {
223 return time_point(std::chrono::duration_cast<duration>(
224 std::chrono::system_clock::now().time_since_epoch()));
243 typedef std::chrono::duration<std::int64_t>
Seconds;
255 typedef duration::rep
rep;
258 static constexpr
bool is_steady =
false;
259 static time_point
now() noexcept {
260 return time_point(std::chrono::duration_cast<duration>(
261 std::chrono::system_clock::now().time_since_epoch()));
272 #ifdef BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG 273 #warning POSIX nanosecond 278 template <
class ISTime>
280 return boost::posix_time::ptime((std::time_t)t.seconds());
285 #endif // #ifndef INTERSTELLAR_HPP
TimePoint< FemtoClock, duration > time_point
Provides Interstellar Time in Nanoseconds.
TimePoint< SecondClock, duration > time_point
constexpr TimePoint(const std::chrono::duration< OtherRep, OtherPeriod > &od)
Constructs a TimePoint from a duration.
Provides Interstellar Time in Femtoseconds.
static constexpr TimePoint max()
Returns the latest time that can be represented.
MilliClock::time_point MilliTime
A point in time in Interstellar Time stored in Milliseconds.
TimePoint & operator=(const TimePoint< OtherClock, OtherDuration > &otp)
Assigns a new time from another TimePoint using different template parameters.
boost::multiprecision::int128_t int128_t
The type used for 128-bit integers.
static time_point now() noexcept
std::chrono::duration< std::int64_t > Seconds
Stores a duration in seconds.
SecondClock::time_point SecondTime
A point in time in Interstellar Time stored in Seconds.
const int128_t OneE15
1e15 in a 128-bit integer.
TimePoint< MilliClock, duration > time_point
static time_point now() noexcept
An extention to the C++ std::chrono::time_point template to make time points easier to work with...
static time_point now() noexcept
std::chrono::duration< int128_t, std::femto > Femtoseconds
Stores a duration in femtoseconds.
Provides Interstellar Time in seconds.
FemtoClock::time_point FemtoTime
A point in time in Interstellar Time stored in Femtoseconds.
TimePoint< NanoClock, duration > time_point
TimePoint & operator=(const TimePoint &)=default
constexpr TimePoint(const std::chrono::time_point< OtherClock, OtherDuration > &otp)
Constructs a TimePoint from a std::chrono::time_point.
static time_point now() noexcept
constexpr TimePoint()=default
const int128_t OneE12
1e12 in a 128-bit integer.
static constexpr TimePoint min()
Returns the earlist time that can be represented.
std::chrono::duration< std::int64_t, std::milli > Milliseconds
Stores a duration in milliseconds.
const int128_t OneE6
1e6 in a 128-bit integer.
std::chrono::duration< std::uint64_t, std::nano > Nanoseconds
Stores a duration in nanoseconds.
boost::posix_time::ptime EarthTimeTAI(const ISTime &t)
Provides Interstellar Time in Milliseconds.
GenericClock< duds::data::GenericValue, double, duds::time::interstellar::NanoTime, float > Clock
General use clock driver type.
NanoClock::time_point NanoTime
A point in time in Interstellar Time stored in Nanoseconds.