| Crates.io | fuzzymonth |
| lib.rs | fuzzymonth |
| version | 0.2.0 |
| created_at | 2025-01-07 22:56:58.057269+00 |
| updated_at | 2025-01-07 23:22:17.074879+00 |
| description | A fuzzy month parser which handles a variety of input formats. |
| homepage | https://github.com/mre/fuzzymonth |
| repository | https://github.com/mre/fuzzymonth |
| max_upload_size | |
| id | 1507820 |
| size | 33,008 |
A robust, user-friendly Rust library for parsing month names with built-in fuzzy matching. It handles various formats, typos, and international month names.
Add to your Cargo.toml:
[dependencies]
fuzzymonth = "0.1.0"
Basic usage:
use fuzzymonth::{parse_month, Month};
fn main() {
// Standard formats
assert_eq!(parse_month("January").unwrap(), Month::January);
assert_eq!(parse_month("feb").unwrap(), Month::February);
// International support
assert_eq!(parse_month("enero").unwrap(), Month::January); // Spanish
assert_eq!(parse_month("fΓ©vrier").unwrap(), Month::February); // French
// Handles typos
assert_eq!(parse_month("septemer").unwrap(), Month::September);
assert_eq!(parse_month("agust").unwrap(), Month::August);
// Various formats
assert_eq!(parse_month("1st").unwrap(), Month::January);
assert_eq!(parse_month("03").unwrap(), Month::March);
// Even handles messy input
assert_eq!(parse_month(" JANUARY ").unwrap(), Month::January);
assert_eq!(parse_month("j@nuary").unwrap(), Month::January);
}
fuzzymonth comes with a friendly interactive CLI tool for testing month parsing:
# Install from crates.io
cargo install fuzzymonth
# Or run directly from source
cargo run
You'll get an interactive prompt where you can test various month formats:
π Fuzzy Month Parser
Type a month name (any format) and press Enter
Press Ctrl+C or Enter an empty line to exit
β january
β January (1)
β feb
β February (2)
β septembr
β September (9)
β enero
β January (1)
β xyz
β Invalid input: xyz
β [Enter]
π Goodbye!
The library uses a multi-step approach to parse month names:
The library is extensively tested with:
Contributions are welcome! Here are some ways you can help:
Please ensure tests pass and add new tests for any added functionality.
Built with π for real-world month parsing. Because dates are hard, and users are creative.