//! Provides a simple interface for mapping between numbers (e.g. 2) and month names (e.g. "February").

use std::collections::HashMap;

use crate::error::Error;

/// Maps between month numbers and month names.
const MONTHS: [(u32, &str); 12] = [
    (1, "January"),
    (2, "February"),
    (3, "March"),
    (4, "April"),
    (5, "May"),
    (6, "June"),
    (7, "July"),
    (8, "August"),
    (9, "September"),
    (10, "October"),
    (11, "November"),
    (12, "December"),
];

pub fn get_month_name(month_number: u32) -> String {
    let months = HashMap::from(MONTHS);
    match months.get(&month_number) {
        Some(n) => n.to_string(),
        None => (Error::InvalidMonth (month_number)).throw(),
    }
}