47 if (
this == &other)
return *
this;
49 count_ = other.count_;
50 literal_ = std::move(other.literal_);
51 valid_ = other.valid_;
54 other.literal_.clear();
58 bool valid() const noexcept {
return valid_ && count_ >= 1 && unit_ok(unit_); }
60 int count() const noexcept {
return count_; }
61 const std::string&
literal() const noexcept {
return literal_; }
90 return a.valid() == b.valid() && a.unit_ == b.unit_ && a.count_ == b.count_
91 && a.literal_ == b.literal_;
181 std::string_view timezone);
251 if (start_minutes_ < 0 || start_minutes_ >= 1440)
return false;
252 if (end_minutes_ < 0 || end_minutes_ > 1440)
return false;
253 const bool expect_full = (end_minutes_ != 1440 && start_minutes_ == end_minutes_);
254 const bool expect_wrap = (!expect_full && end_minutes_ < start_minutes_);
255 return full_day_ == expect_full && wraps_ == expect_wrap;
259 bool wraps() const noexcept {
return wraps_; }
260 bool full_day() const noexcept {
return full_day_; }
263 friend std::optional<SessionCalendar>
parse_session(std::string_view, std::string_view);
265 : start_minutes_(start), end_minutes_(end), wraps_(
wraps), full_day_(
full_day) {}
266 int start_minutes_ = 0;
267 int end_minutes_ = 0;
269 bool full_day_ =
false;
283 if (
this == &other)
return *
this;
284 timezone_ = std::move(other.timezone_);
285 literal_ = std::move(other.literal_);
286 windows_ = std::move(other.windows_);
287 day_mask_ = other.day_mask_;
288 origin_minutes_ = other.origin_minutes_;
289 all_day_ = other.all_day_;
290 valid_ = other.valid_;
291 other.valid_ =
false;
293 other.origin_minutes_ = 0;
294 other.all_day_ =
false;
295 other.timezone_.clear();
296 other.literal_.clear();
297 other.windows_.clear();
302 const
std::
string&
timezone() const noexcept {
return timezone_; }
303 const std::string&
literal() const noexcept {
return literal_; }
304 const std::vector<SessionWindow>&
windows() const noexcept {
return windows_; }
305 std::uint8_t
day_mask() const noexcept {
return day_mask_; }
307 bool all_day() const noexcept {
return all_day_; }
310 friend std::optional<SessionCalendar>
parse_session(std::string_view, std::string_view);
313 std::vector<SessionWindow>
windows,
324 std::string timezone_;
325 std::string literal_;
326 std::vector<SessionWindow> windows_;
327 std::uint8_t day_mask_ = 0;
328 int origin_minutes_ = 0;
329 bool all_day_ =
false;
333std::optional<SessionCalendar>
parse_session(std::string_view session,
334 std::string_view timezone);
354 const int64_t z = days + 719468;
355 const int64_t era = (z >= 0 ? z : z - 146096) / 146097;
356 const int64_t doe = z - era * 146097;
357 const int64_t yoe = (doe - doe / 1460 + doe / 36524 - doe / 146096) / 365;
358 const int64_t doy = doe - (365 * yoe + yoe / 4 - yoe / 100);
359 const int64_t mp = (5 * doy + 2) / 153;
360 const int64_t month = mp < 10 ? mp + 3 : mp - 9;
362 static_cast<int>(month),
363 static_cast<int>(doy - (153 * mp + 2) / 5 + 1)};
371 const int64_t era = (year >= 0 ? year : year - 399) / 400;
372 const int64_t yoe = year - era * 400;
373 const int64_t doy = (153 * (month + (month > 2 ? -3 : 9)) + 2) / 5 + day - 1;
374 const int64_t doe = yoe * 365 + yoe / 4 - yoe / 100 + doy;
375 return era * 146097 + doe - 719468;
444 std::vector<std::pair<int64_t, int64_t>>
spans;
448 for (
const auto& span :
spans) {
449 if (span.first <= ms && ms < span.second)
return true;
SessionCalendar & operator=(const SessionCalendar &)=default
SessionCalendar()=default
SessionCalendar(const SessionCalendar &)=default
SessionCalendar & operator=(SessionCalendar &&other) noexcept
const std::string & timezone() const noexcept
friend std::optional< SessionCalendar > parse_session(std::string_view, std::string_view)
const std::string & literal() const noexcept
SessionCalendar(SessionCalendar &&other) noexcept
int origin_minutes() const noexcept
bool all_day() const noexcept
std::uint8_t day_mask() const noexcept
const std::vector< SessionWindow > & windows() const noexcept
bool valid() const noexcept
bool valid() const noexcept
int end_minutes() const noexcept
friend std::optional< SessionCalendar > parse_session(std::string_view, std::string_view)
int start_minutes() const noexcept
bool wraps() const noexcept
bool full_day() const noexcept
TimeframeUnit unit() const noexcept
bool is_fixed() const noexcept
Timeframe & operator=(const Timeframe &)=default
friend bool operator==(const Timeframe &, const Timeframe &) noexcept
friend std::optional< Timeframe > parse_timeframe(std::string_view)
Timeframe(const Timeframe &)=default
bool is_calendar() const noexcept
Timeframe(Timeframe &&other) noexcept
int count() const noexcept
Timeframe & operator=(Timeframe &&other) noexcept
bool valid() const noexcept
const std::string & literal() const noexcept
bool operator==(const Timeframe &a, const Timeframe &b) noexcept
std::optional< TimezoneIdentityDescriptor > timezone_identity_descriptor(std::string_view timezone)
std::optional< Timeframe > parse_timeframe(std::string_view text)
constexpr int64_t native_civil_days(int64_t year, int month, int day) noexcept
bool pairing_aggregates(const TimeframeCompatibility &pairing) noexcept
@ StreamMonthlyInputRefused
std::optional< int64_t > session_week_ordinal(const SessionCalendar &calendar, int64_t ms)
std::optional< CivilResolution > resolve_civil(std::string_view timezone, int year, int month, int day, int hour, int minute, int second=0)
bool in_session(const SessionCalendar &calendar, int64_t ms)
std::optional< int64_t > session_day_ordinal(const SessionCalendar &calendar, int64_t ms)
constexpr NativeCivilDate native_civil_date(int64_t days) noexcept
bool timezone_accepted(std::string_view timezone)
std::optional< int64_t > session_month_ordinal(const SessionCalendar &calendar, int64_t ms)
TimeframeCompatibility stream_compatibility(const Timeframe &input, const Timeframe &script)
std::optional< NativeSessionDay > session_day_at(const SessionCalendar &calendar, int64_t ms)
std::optional< int64_t > period_key(const SessionCalendar &calendar, const Timeframe &tf, int64_t ms)
std::optional< NativeInterval > interval_containing(const SessionCalendar &calendar, const Timeframe &tf, int64_t ms)
std::optional< SessionCalendar > parse_session(std::string_view session, std::string_view timezone)
TimeframeCompatibility compatibility(const Timeframe &input, const Timeframe &script)
int64_t next_period_open_ms
int64_t next_input_open_ms
int64_t last_traded_close_ms
std::vector< std::pair< int64_t, int64_t > > spans
bool holds(int64_t ms) const noexcept
bool in_session_at(int64_t ms) const noexcept
std::uint64_t resource_digest
std::string effective_definition
std::uint32_t semantics_version
static constexpr std::uint32_t kSemanticsVersion
std::vector< std::string > resource_paths
std::string zoneinfo_root
bool valid() const noexcept