fn add_int(dur: Duration, date: Date) -> Result<DateArithmeticOutput, TimeSeriesError> {
        // Add days first for negative durations & last for positive
        let days_first = !dur.forwards();

        let mut output = dur.add_once(date, days_first, true)?;

        // Add the other days that could result from the addition / subtraction
        if dur.is_multiple_output(date)? {
            // Deal with days that could have multiplied because both routes give rise to
            // an invalid date, so the invalid date is truncated to month end
            // Only ever happens at end of month
            if Self::is_eom(date) {
                let day = date.day() as i32 + cmp::max(dur.days, 0) + 1;
                let (year, month) = dur.add_ym(date);
                let lim = days_in_year_month(year, month) as i32 + cmp::min(dur.days, 0) + 1;
                for i in day..lim {
                    // N.B. might never loop here & that's OK
                    let temp = i as u8;
                    if let Ok(d) = Date::from_calendar_date(year, month, temp) {
                        output.append(d);
                    }
                }
            }

            // Check for date by adding with the days order reversed
            let d = dur.add_once(date, !days_first, false)?.primary();
            if !output.contains(d) {
                output.append(d);
            }
        }
        Ok(output)
    }
// region: addition
/// Root internal method for performing addition.
/// Called by the trait implementations which consider the
/// various combinations of adding and subtracting Dates and
/// Durations
addition
Root internal method for performing addition.
Called by the trait implementations which consider the
various combinations of adding and subtracting Dates and
Durations
addition Root internal method for performing addition . Called by the trait implementations which consider the various combinations of adding and subtracting Dates and Durations
fn add_int(dur: Duration, date: Date) -> Result<DateArithmeticOutput, TimeSeriesError> {
        // Add days first for negative durations & last for positive
        let days_first = !dur.forwards();
        let mut output = dur.add_once(date, days_first, true)?;
        // Add the other days that could result from the addition / subtraction
        if dur.is_multiple_output(date)? {
            // Deal with days that could have multiplied because both routes give rise to
            // an invalid date, so the invalid date is truncated to month end
            // Only ever happens at end of month
            if Self::is_eom(date) {
                let day = date.day() as i32 + cmp::max(dur.days, 0) + 1;
                let (year, month) = dur.add_ym(date);
                let lim = days_in_year_month(year, month) as i32 + cmp::min(dur.days, 0) + 1;
                for i in day..lim {
                    // N.B. might never loop here & that's OK
                    let temp = i as u8;
                    if let Ok(d) = Date::from_calendar_date(year, month, temp) {
                        output.append(d);
                    }
                }
            }
            // Check for date by adding with the days order reversed
            let d = dur.add_once(date, !days_first, false)?.primary();
            if !output.contains(d) {
                output.append(d);
            }
        }
        Ok(output)
    }
fn add_int ( dur : Duration , date : Date ) -> Result < DateArithmeticOutput , TimeSeriesError > { // Add days first for negative durations & last for positive let days_first = ! dur . forwards ( ) ; let mut output = dur . add_once ( date , days_first , true ) ? ; // Add the other days that could result from the addition / subtraction if dur . is_multiple_output ( date ) ? { // Deal with days that could have multiplied because both routes give rise to // an invalid date, so the invalid date is truncated to month end // Only ever happens at end of month if Self :: is_eom ( date ) { let day = date . day ( ) as i32 + cmp :: max ( dur . days , 0 ) + 1 ; let ( year , month ) = dur . add_ym ( date ) ; let lim = days_in_year_month ( year , month ) as i32 + cmp :: min ( dur . days , 0 ) + 1 ; for i in day .. lim { // N.B. might never loop here & that's OK let temp = i as u8 ; if let Ok ( d ) = Date :: from_calendar_date ( year , month , temp ) { output . append ( d ) ; } } } // Check for date by adding with the days order reversed let d = dur . add_once ( date , ! days_first , false ) ? . primary ( ) ; if ! output . contains ( d ) { output . append ( d ) ; } } Ok ( output ) }
region: addition
Root internal method for performing addition.
region : addition Root internal method for performing addition .
dur
Duration
date
Date
dur
Duration
date
Date