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>) {
56 if constexpr (std::is_same_v<std::decay_t<T>,
CivilTime>) {
63template <
typename TargetA,
typename TargetB,
typename T>
65 if constexpr (std::is_same_v<std::decay_t<T>,
CivilTime>) {
72template <
typename Target,
typename T>
74 if constexpr (std::is_same_v<std::decay_t<T>,
CivilTime>) {
81template <
typename TargetA,
typename TargetB,
typename T>
83 if constexpr (std::is_same_v<std::decay_t<T>,
CivilTime>) {
92template <
typename T = ModifiedJulianDate<scale::TT>>
class Period {
113 template <
typename Target>
auto to()
const {
120 template <
typename TargetA,
typename TargetB>
auto to()
const {
122 auto converted_end = detail::convert_period_endpoint<TargetA, TargetB>(
end());
141 template <
typename TargetType = qtty::DayTag>
142 qtty::Quantity<typename qtty::ExtractTag<TargetType>::type>
duration()
const {
148 template <
typename TargetType = qtty::DayTag>
149 qtty::Quantity<typename qtty::ExtractTag<TargetType>::type>
length()
const {
156 "Period::intersection");
166 std::size_t
count = 0;
168 "Period::union_with");
169 std::vector<Period<T>>
result;
171 for (std::size_t
i = 0;
i <
count; ++
i)
177 std::vector<tempoch_period_mjd_t> raw;
178 raw.reserve(
others.size());
180 raw.push_back(
p.c_inner());
184 "Period::complement_of");
185 std::vector<Period<T>>
result;
187 for (std::size_t
i = 0;
i <
n; ++
i)
205 std::vector<tempoch_period_mjd_t> raw;
208 raw.push_back(
p.c_inner());
214 std::vector<Period<T>>
result;
216 for (std::size_t
i = 0;
i <
count; ++
i)
236 "intersect_periods");
237 return detail::from_alloc<T>(
out,
n);
248 return detail::from_alloc<T>(
out,
n);
257 "normalize_periods");
258 return detail::from_alloc<T>(
out,
n);
262 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
auto to_with(const TimeContext &ctx) const
Period(const T &start, const T &end)
auto to_with(const TimeContext &ctx) const
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).
Immutable conversion context for UT1 and historical UTC routes.
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)
auto convert_period_endpoint_with(const T &value, const TimeContext &ctx)
std::vector< Period< T > > from_alloc(tempoch_period_mjd_t *ptr, std::size_t count)
auto convert_period_endpoint(const T &value)
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.