Skip to main content

JointCalendar

Struct JointCalendar 

pub struct JointCalendar {
    members: Vec<Arc<dyn Calendar>>,
    rule: JointCalendarRule,
    merged: BusinessDayGrid,
    name: String,
}
Expand description

A calendar combining several underlying calendars by a JointCalendarRule.

The member calendars are immutable after construction (the Calendar trait exposes no mutators), so JointCalendar::new materializes the joint classification into a single merged business-day grid over the generated holiday horizon — per-day queries and business-day counts inside the horizon are O(1) and never fan out to the members. Outside the horizon the members are probed directly (each degrades per its own documented fallback), so the joint classification is unchanged everywhere.

Fields§

§members: Vec<Arc<dyn Calendar>>§rule: JointCalendarRule§merged: BusinessDayGrid

Merged member classification over the generated horizon; see the type docs for the members-immutable precondition this build relies on.

§name: String

The members’ names comma-joined where the rule joins holidays — the spelling the calendar parser builds this join from — else Joint.

Implementations§

§

impl JointCalendar

pub fn new(members: Vec<Arc<dyn Calendar>>, rule: JointCalendarRule) -> Self

Combines members under the given rule.

§Panics

Never in practice. The grid spans the data calendars’ own fixed horizon (data_calendar::horizon_start to horizon_end), whose bounds are date literals chrono accepts.

fn count_half_open(&self, from: NaiveDate, to: NaiveDate) -> i64

Business days in the half-open range [from, to) (from <= to): the in-horizon part is an O(1) prefix-sum subtraction on the merged grid; any out-of-horizon spill steps by day against the members (no holiday data exists there, so the spill is rare and short in practice).

fn count_forward( &self, from: NaiveDate, to: NaiveDate, include_first: bool, include_last: bool, ) -> i64

Forward-ordered (from < to) count with endpoint-inclusion flags.

Trait Implementations§

§

impl Calendar for JointCalendar

§

fn name(&self) -> &str

A short name for the calendar (diagnostic).
§

fn is_weekend(&self, date: NaiveDate) -> bool

Whether date is a weekend (Saturday or Sunday by default).
§

fn is_holiday(&self, date: NaiveDate) -> bool

Whether date is closed for a reason beyond the weekend: a listed closure, not a Saturday. A weekend day carrying no listed closure is not a holiday, and the default answers false for every date accordingly. Read more
§

fn is_business_day(&self, date: NaiveDate) -> bool

Whether date is a good business day (not a weekend, not a holiday).
§

fn business_days_between(&self, start: NaiveDate, end: NaiveDate) -> i64

The number of business days in the half-open interval [start, end). Returns 0 when start >= end. This is the count BUS/252 divides by 252. The default iterates day by day; the data-backed calendars (DataCalendar, JointCalendar) override it with an O(1) prefix-sum subtraction over their precomputed business-day grid.
§

fn business_days_between_inc( &self, from: NaiveDate, to: NaiveDate, include_first: bool, include_last: bool, ) -> i64

The number of business days between from and to with caller-controlled inclusion of each endpoint. When to < from the count is the negation of the forward count with the inclusion flags swapped; when to == from the result is 1 only if both endpoints are included and the date is a business day. The two-argument Calendar::business_days_between is the [start, end) case (include_first = true, include_last = false).
§

fn adjust( &self, date: NaiveDate, convention: BusinessDayConvention, ) -> NaiveDate

Rolls date to a business day per convention.
§

fn advance( &self, date: NaiveDate, period: Period, convention: BusinessDayConvention, end_of_month: bool, ) -> NaiveDate

Advances date by period (calendar arithmetic), then adjusts the result per convention. Read more
§

fn advance_with_roll( &self, date: NaiveDate, period: Period, roll: RollConvention, convention: BusinessDayConvention, end_of_month: bool, ) -> NaiveDate

Advances date by period, snaps the result by roll, then adjusts it per convention — the roll-aware form of Calendar::advance, which is this method under RollConvention::None. Read more
§

fn end_of_month(&self, date: NaiveDate) -> NaiveDate

The last business day of date’s month — the latest good business day in the month (weekends and holidays rolled back). Read more
§

fn is_end_of_month(&self, date: NaiveDate) -> bool

Whether date is the last business day of its month (its business end-of-month). Strict: a trailing weekend day after the last business day is not end-of-month (use Calendar::is_month_end_anchor for the end-of-month roll gate, which also fires on those trailing days).
§

fn is_month_end_anchor(&self, date: NaiveDate) -> bool

Whether date anchors the end-of-month roll: it is on or after its month’s last business day. This fires for the last business day and any trailing weekend/holiday days (so a month-end falling on a weekend, e.g. Sat 28-Feb, still anchors the rule), matching the end-of-month advance behaviour in Calendar::advance.
§

fn next_business_day(&self, date: NaiveDate) -> NaiveDate

The first business day on or after date.
§

fn previous_business_day(&self, date: NaiveDate) -> NaiveDate

The first business day on or before date.
§

fn add_business_days(&self, date: NaiveDate, n: i64) -> NaiveDate

Shifts date by n good business days, skipping weekends and holidays. Negative n looks backward; n == 0 returns date unchanged (even if it is itself a holiday). Each counted step lands on a business day — this is the primitive a fixing lag (e.g. -2 business days off the reset anchor) is built on.
§

fn holidays( &self, from: NaiveDate, to: NaiveDate, include_weekends: bool, ) -> Vec<NaiveDate>

The holidays in the inclusive range [from, to], ascending. Weekends are included only when include_weekends is set; a “holiday” is any non-business day.
§

fn business_days(&self, from: NaiveDate, to: NaiveDate) -> Vec<NaiveDate>

The business days in the inclusive range [from, to], ascending.
§

impl Clone for JointCalendar

§

fn clone(&self) -> JointCalendar

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.