astrolabe 0.5.4

Date and time library for Rust. Aims to be feature rich, lightweight and easy-to-use.
Documentation
/// Returns leap years between the year 0001 and the given year (exluding the year itself)
pub(crate) fn leap_years(mut year: i32) -> u32 {
    if year.is_positive() {
        year -= 1;
    }
    if year.is_negative() {
        year += 1;
    }
    let year_abs = year.abs();
    let mut leaps = year_abs / 4 - year_abs / 100 + year_abs / 400;
    if year.is_negative() {
        leaps += 1;
    }
    leaps as u32
}

/// Checks if the given year is a leap year
pub(crate) fn is_leap_year(mut year: i32) -> bool {
    if year.is_negative() {
        year += 1;
    }
    year % 4 == 0 && (year % 100 != 0 || year % 400 == 0)
}