1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/// Determine if year is a leap year.
///
/// ## Arguments
/// year
///
/// ## Returns
/// true or false
pub fn is_leap_year(input_year: u32) -> bool {
    let year = input_year as f64;

    if year % 4.0 == 0.0 {
        if year % 100.0 == 0.0 {
            return if year % 400.0 == 0.0 { true } else { false };
        } else {
            return true;
        }
    } else {
        return false;
    }
}

/// Round an f64 primitive to the specified number of decimal places.
pub fn round_f64(input_value: f64, places: usize) -> f64 {
    return format!("{:.width$}", input_value, width = places)
        .parse::<f64>()
        .unwrap();
}