14 #include <boost/date_time/gregorian/gregorian.hpp> 32 using std::unique_ptr;
49 static const boost::gregorian::date &
dateZero();
50 static const boost::posix_time::ptime &
timeZero();
55 static void make(
const std::string &path =
"/usr/share/zoneinfo-leaps/UTC");
57 typedef duration::rep
rep;
59 typedef std::chrono::time_point<Earth, duration>
time_point;
61 time_point
now() noexcept {
63 return time_point(std::chrono::duration_cast<duration, rep, period>(
64 std::chrono::system_clock::now().time_since_epoch()));
69 boost::gregorian::date
date(
72 template <
class ISTime>
76 boost::gregorian::date
date(
const ISTime &t)
const {
78 std::chrono::duration_cast<interstellar::Seconds>(
89 template <
class ISTime>
93 std::time_t
timeUtc(
const ISTime &t)
const {
95 std::chrono::duration_cast<interstellar::Seconds>(
107 template <
class ISTime>
113 std::chrono::duration_cast<interstellar::Seconds>(
121 boost::posix_time::ptime
posix(
124 template <
class ISTime>
128 boost::posix_time::ptime
posix(
const ISTime &t)
const {
130 std::chrono::duration_cast<duds::time::interstellar::Milliseconds>(
141 template <
class ISTime>
147 std::chrono::duration_cast<duds::time::interstellar::Milliseconds>(
158 template <
class Clock,
class Duration>
163 if (!bound.
within(time)) {
166 assert(bound.
within(time));
174 template <
class ISTime>
175 void date(ISTime &dest,
const boost::gregorian::date &src) {
186 template <
class ISTime>
187 void time(ISTime &dest,
const boost::posix_time::ptime &src) {
190 (src -
timeZero()).total_milliseconds()
198 extern unique_ptr<Earth>
earth;
205 template <
class ISTime>
206 inline boost::gregorian::date
ToDate(
const ISTime &t) {
208 std::chrono::duration_cast<duds::time::interstellar::Seconds>(
219 template <
class ISTime>
220 inline boost::posix_time::ptime
ToPosix(
const ISTime &t) {
222 std::chrono::duration_cast<duds::time::interstellar::Milliseconds>(
230 #endif // #ifndef PLANETARY_HPP boost::posix_time::ptime posix(const ISTime &t) const
Converts from IST to UTC and provides a ptime result.
boost::gregorian::date dateUtcToTai(const ISTime &t) const
Converts from IST to UTC and provides a date result.
static const boost::gregorian::date & dateZero()
std::time_t timeUtc(const duds::time::interstellar::SecondTime &t) const
Converts from IST to UTC and provides a std::time_t result.
MilliClock::time_point MilliTime
A point in time in Interstellar Time stored in Milliseconds.
boost::gregorian::date ToDate(const ISTime &t)
Converts without applying any modification to the time, so if the input is in TAI, the result will be, too.
boost::gregorian::date date(const ISTime &t) const
Converts from IST to UTC and provides a date result.
std::chrono::duration< std::int64_t > Seconds
Stores a duration in seconds.
duds::time::interstellar::Seconds leapSeconds(const duds::time::interstellar::SecondTime &when) const
Returns the sum of all leap seconds in use at the given time.
SecondClock::time_point SecondTime
A point in time in Interstellar Time stored in Seconds.
const Count & leaps() const
Returns the leap seconds in this period.
std::chrono::time_point< Earth, duration > time_point
boost::posix_time::ptime ToPosix(const ISTime &t)
Converts without applying any modification to the time, so if the input is in TAI, the result will be, too.
boost::gregorian::date date(const duds::time::interstellar::SecondTime &t) const
Converts from IST to UTC and provides a date result.
std::time_t timeUtc(const ISTime &t) const
Converts from IST to UTC and provides a std::time_t result.
Stores when leap seconds occur to allow conversions between Interstellar Time or TAI and planetary ti...
An extention to the C++ std::chrono::time_point template to make time points easier to work with...
void time(ISTime &dest, const boost::posix_time::ptime &src)
Converts a POSIX time into one of the time formats defined inside the duds::time::interstellar namesp...
std::chrono::duration< int128_t, std::femto > Femtoseconds
Stores a duration in femtoseconds.
bool within(const duds::time::interstellar::TimePoint< OtherClock, OtherDuration > &time) const
Returns true if the given provided time is within bounds.
static constexpr bool is_steady
boost::gregorian::date dateUtcToTai(const duds::time::interstellar::SecondTime &t) const
Converts from UTC to TAI and provides a date result.
void date(ISTime &dest, const boost::gregorian::date &src)
Converts a Gregorian calendar date into one of the time formats defined inside the duds::time::inters...
boost::posix_time::ptime posixUtcToTai(const ISTime &t) const
Converts from UTC to TAI and provides a ptime result.
duds::time::interstellar::Femtoseconds duration
unique_ptr< Earth > earth
std::chrono::duration< std::int64_t, std::milli > Milliseconds
Stores a duration in milliseconds.
void addLeapSeconds(duds::time::interstellar::TimePoint< Clock, Duration > &time)
Adds leap seconds to the given time in UTC, resulting in TAI.
LeapBounds getLeapBounds(const duds::time::interstellar::SecondTime time) const
Create a LeapBounds object with the data for the time period covered for the given time...
static const boost::posix_time::ptime & timeZero()
static void make(const std::string &path="/usr/share/zoneinfo-leaps/UTC")
Makes the Earth planetary time object using the given zoneinfo file for data on leap seconds...
boost::posix_time::ptime posix(const duds::time::interstellar::MilliTime &t) const
Converts from IST to UTC and provides a ptime result.
time_point now() noexcept
A container holding the number of leap seconds and the time bounds over which the leap seconds are ap...
boost::posix_time::ptime posixUtcToTai(const duds::time::interstellar::MilliTime &t) const
Converts from UTC to TAI and provides a ptime result.