8#include "qtty/qtty.hpp"
27 if constexpr (std::is_same_v<F, format::MJD>) {
35 if constexpr (std::is_same_v<F, format::MJD>) {
53template <
typename T = ModifiedJulianDate<scale::TT>>
class Period {
74 template <
typename TargetType = qtty::DayTag>
75 qtty::Quantity<typename qtty::ExtractTag<TargetType>::type>
duration()
const {
81 template <
typename TargetType = qtty::DayTag>
82 qtty::Quantity<typename qtty::ExtractTag<TargetType>::type>
length()
const {
89 "Period::intersection");
99 std::size_t
count = 0;
101 "Period::union_with");
102 std::vector<Period<T>>
result;
104 for (std::size_t
i = 0;
i <
count; ++
i)
110 std::vector<tempoch_period_mjd_t> raw;
111 raw.reserve(
others.size());
113 raw.push_back(
p.c_inner());
117 "Period::complement_of");
118 std::vector<Period<T>>
result;
120 for (std::size_t
i = 0;
i <
n; ++
i)
138 std::vector<tempoch_period_mjd_t> raw;
141 raw.push_back(
p.c_inner());
147 std::vector<Period<T>>
result;
149 for (std::size_t
i = 0;
i <
count; ++
i)
169 "intersect_periods");
170 return detail::from_alloc<T>(
out,
n);
181 return detail::from_alloc<T>(
out,
n);
190 "normalize_periods");
191 return detail::from_alloc<T>(
out,
n);
195 return os <<
'[' <<
period.start() <<
", " <<
period.end() <<
')';
A typed external encoding of a time instant on scale S.
qtty::Quantity< typename qtty::ExtractTag< TargetType >::type > duration() const
const tempoch_period_mjd_t & c_inner() const noexcept
Period intersection(const Period &other) const
bool contains(const T &point) const noexcept
Period(const T &start, const T &end)
std::vector< Period< T > > union_with(const Period< T > &other) const
static Period from_c(const tempoch_period_mjd_t &c)
std::vector< Period< T > > complement_of(const std::vector< Period< T > > &others) const
qtty::Quantity< typename qtty::ExtractTag< TargetType >::type > length() const
Returns the length of the period (primary name; duration() is a backward-compat alias).
A point in time on scale S, stored as a split J2000-second pair.
static Time from_civil(const CivilTime &civil)
static Time from_encoded(const EncodedTime< S, Fmt > &encoded)
Decode a scalar encoding Fmt into canonical split storage on scale S (default context).
CivilTime to_civil() const
std::vector< tempoch_period_mjd_t > to_raw(const std::vector< Period< T > > &periods)
std::vector< Period< T > > from_alloc(tempoch_period_mjd_t *ptr, std::size_t count)
std::ostream & operator<<(std::ostream &os, const CivilTime &u)
Stream CivilTime as YYYY-MM-DD HH:MM:SS[.nnnnnnnnn].
std::vector< Period< T > > intersect_periods(const std::vector< Period< T > > &a, const std::vector< Period< T > > &b)
std::vector< Period< T > > normalize_periods(const std::vector< Period< T > > &periods)
void validate_periods(const std::vector< Period< T > > &periods)
void check_status(tempoch_status_t status, const char *operation)
Check a tempoch_status_t and throw the appropriate exception on error.
std::vector< Period< T > > union_periods(const std::vector< Period< T > > &a, const std::vector< Period< T > > &b)
constexpr tempoch_scale_tag_t scale_tag_v
static CivilTime from_mjd_value(double mjd)
static double to_mjd_value(const CivilTime &time)
static double to_mjd_value(const EncodedTime< S, F > &time)
static EncodedTime< S, F > from_mjd_value(double mjd)
static Time< S > from_mjd_value(double mjd)
static double to_mjd_value(const Time< S > &time)
Public aliases for tempoch time encodings.