/// Get the transition date for the provided year
///
/// ## Outputs
///
/// * `month`: Month in `[1, 12]`
/// * `month_day`: Day of the month in `[1, 31]`
Get the transition date for the provided year
Get the transition date for the provided year
fn transition_date(&self, year: i32) -> (usize, i64) {
        match *self {
            RuleDay::Julian1WithoutLeap(year_day) => {
                let year_day = year_day as i64;
                let month = match CUMUL_DAY_IN_MONTHS_NORMAL_YEAR.binary_search(&(year_day - 1)) {
                    Ok(x) => x + 1,
                    Err(x) => x,
                };
                let month_day = year_day - CUMUL_DAY_IN_MONTHS_NORMAL_YEAR[month - 1];
                (month, month_day)
            }
            RuleDay::Julian0WithLeap(year_day) => {
                let leap = is_leap_year(year) as i64;
                let cumul_day_in_months = [
                    0,
                    31,
                    59 + leap,
                    90 + leap,
                    120 + leap,
                    151 + leap,
                    181 + leap,
                    212 + leap,
                    243 + leap,
                    273 + leap,
                    304 + leap,
                    334 + leap,
                ];
                let year_day = year_day as i64;
                let month = match cumul_day_in_months.binary_search(&year_day) {
                    Ok(x) => x + 1,
                    Err(x) => x,
                };
                let month_day = 1 + year_day - cumul_day_in_months[month - 1];
                (month, month_day)
            }
            RuleDay::MonthWeekday { month: rule_month, week, week_day } => {
                let leap = is_leap_year(year) as i64;
                let month = rule_month as usize;
                let mut day_in_month = DAY_IN_MONTHS_NORMAL_YEAR[month - 1];
                if month == 2 {
                    day_in_month += leap;
                }
                let week_day_of_first_month_day =
                    rem_euclid(4 + days_since_unix_epoch(year, month, 1), DAYS_PER_WEEK);
                let first_week_day_occurence_in_month =
                    1 + rem_euclid(week_day as i64 - week_day_of_first_month_day, DAYS_PER_WEEK);
                let mut month_day =
                    first_week_day_occurence_in_month + (week as i64 - 1) * DAYS_PER_WEEK;
                if month_day > day_in_month {
                    month_day -= DAYS_PER_WEEK
                }
                (month, month_day)
            }
        }
    }
fn transition_date ( & self , year : i32 ) -> ( usize , i64 ) { match * self { RuleDay :: Julian1WithoutLeap ( year_day ) => { let year_day = year_day as i64 ; let month = match CUMUL_DAY_IN_MONTHS_NORMAL_YEAR . binary_search ( & ( year_day - 1 ) ) { Ok ( x ) => x + 1 , Err ( x ) => x , } ; let month_day = year_day - CUMUL_DAY_IN_MONTHS_NORMAL_YEAR [ month - 1 ] ; ( month , month_day ) } RuleDay :: Julian0WithLeap ( year_day ) => { let leap = is_leap_year ( year ) as i64 ; let cumul_day_in_months = [ 0 , 31 , 59 + leap , 90 + leap , 120 + leap , 151 + leap , 181 + leap , 212 + leap , 243 + leap , 273 + leap , 304 + leap , 334 + leap , ] ; let year_day = year_day as i64 ; let month = match cumul_day_in_months . binary_search ( & year_day ) { Ok ( x ) => x + 1 , Err ( x ) => x , } ; let month_day = 1 + year_day - cumul_day_in_months [ month - 1 ] ; ( month , month_day ) } RuleDay :: MonthWeekday { month : rule_month , week , week_day } => { let leap = is_leap_year ( year ) as i64 ; let month = rule_month as usize ; let mut day_in_month = DAY_IN_MONTHS_NORMAL_YEAR [ month - 1 ] ; if month == 2 { day_in_month += leap ; } let week_day_of_first_month_day = rem_euclid ( 4 + days_since_unix_epoch ( year , month , 1 ) , DAYS_PER_WEEK ) ; let first_week_day_occurence_in_month = 1 + rem_euclid ( week_day as i64 - week_day_of_first_month_day , DAYS_PER_WEEK ) ; let mut month_day = first_week_day_occurence_in_month + ( week as i64 - 1 ) * DAYS_PER_WEEK ; if month_day > day_in_month { month_day -= DAYS_PER_WEEK } ( month , month_day ) } } }
Get the transition date for the provided year
Get the transition date for the provided year
&self
year
i32
outputs
None