fn add_once(
        &self,
        date: Date,
        days_first: bool,
        first_pass: bool,
    ) -> Result<DateArithmeticOutput, TimeSeriesError> {
        // Assign the internal date variable & add days, if that's what we're doing
        let mut temp = if days_first {
            self.add_days(date)?
        } else {
            date
        };
        let day = temp.day();

        let (year, month) = self.add_ym(temp);

        // Try to create the intermediate date
        temp = match Date::from_calendar_date(year, month, day) {
            Ok(d) => d,
            Err(_) => {
                if !first_pass {
                    // If all else fails then take the day at the end of the month being tried
                    let d = Date::from_calendar_date(year, month, days_in_year_month(year, month))
                        .unwrap_or(date);
                    return Ok(DateArithmeticOutput::new(d));
                }
                return self.add_once(date, !days_first, false);
            }
        };

        // Add days as required
        if !days_first {
            temp = self.add_days(temp)?;
        }
        Ok(DateArithmeticOutput::new(temp))
    }
/// Internal method for addition. Allows us to try days first or second and if it
/// fails, the other way around.
///
/// If the other way round also fails, will truncate
/// the failing intermediate date to end of month
Internal method for addition. Allows us to try days first or second and if it
fails, the other way around.

If the other way round also fails, will truncate
the failing intermediate date to end of month
Internal method for addition . Allows us to try days first or second and if it fails the other way around . If the other way round also fails will truncate the failing intermediate date to end of month
fn add_once(
        &self,
        date: Date,
        days_first: bool,
        first_pass: bool,
    ) -> Result<DateArithmeticOutput, TimeSeriesError> {
        // Assign the internal date variable & add days, if that's what we're doing
        let mut temp = if days_first {
            self.add_days(date)?
        } else {
            date
        };
        let day = temp.day();
        let (year, month) = self.add_ym(temp);
        // Try to create the intermediate date
        temp = match Date::from_calendar_date(year, month, day) {
            Ok(d) => d,
            Err(_) => {
                if !first_pass {
                    // If all else fails then take the day at the end of the month being tried
                    let d = Date::from_calendar_date(year, month, days_in_year_month(year, month))
                        .unwrap_or(date);
                    return Ok(DateArithmeticOutput::new(d));
                }
                return self.add_once(date, !days_first, false);
            }
        };
        // Add days as required
        if !days_first {
            temp = self.add_days(temp)?;
        }
        Ok(DateArithmeticOutput::new(temp))
    }
fn add_once ( & self , date : Date , days_first : bool , first_pass : bool , ) -> Result < DateArithmeticOutput , TimeSeriesError > { // Assign the internal date variable & add days, if that's what we're doing let mut temp = if days_first { self . add_days ( date ) ? } else { date } ; let day = temp . day ( ) ; let ( year , month ) = self . add_ym ( temp ) ; // Try to create the intermediate date temp = match Date :: from_calendar_date ( year , month , day ) { Ok ( d ) => d , Err ( _ ) => { if ! first_pass { // If all else fails then take the day at the end of the month being tried let d = Date :: from_calendar_date ( year , month , days_in_year_month ( year , month ) ) . unwrap_or ( date ) ; return Ok ( DateArithmeticOutput :: new ( d ) ) ; } return self . add_once ( date , ! days_first , false ) ; } } ; // Add days as required if ! days_first { temp = self . add_days ( temp ) ? ; } Ok ( DateArithmeticOutput :: new ( temp ) ) }
Internal method for addition.
Internal method for addition .
&self
date
Date
days_first
bool
first_pass
bool
&self
date
Date
days_first
bool
first_pass
bool