php-dates 0.2.1

PHP date() patterns for Rust: strict createFromFormat-style parsing, a pattern resolution contract and a Day.js export, with no framework dependency
Documentation
//! English day and month names, as PHP prints and reads them without a locale.

pub(crate) const DAYS: [&str; 7] = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"];

pub(crate) const MONTHS: [&str; 12] = [
    "January",
    "February",
    "March",
    "April",
    "May",
    "June",
    "July",
    "August",
    "September",
    "October",
    "November",
    "December",
];

/// A run of ASCII letters from the start of `text`.
pub(crate) fn word(text: &str) -> &str {
    let length = text.bytes().take_while(u8::is_ascii_alphabetic).count();
    &text[..length]
}

/// Months as PHP also reads them: Roman numerals.
const ROMAN: [&str; 12] = ["i", "ii", "iii", "iv", "v", "vi", "vii", "viii", "ix", "x", "xi", "xii"];

/// A month by full name, three-letter abbreviation, `sept` or Roman numeral, in any letter case: `(1..=12, length)`.
pub(crate) fn month(text: &str) -> Option<(u32, usize)> {
    let word = word(text);
    let lower = word.to_ascii_lowercase();
    let named = MONTHS.iter().position(|name| {
        let name = name.to_ascii_lowercase();
        lower == name || lower == name[..3] || (lower == "sept" && name == "september")
    });
    let found = named.or_else(|| ROMAN.iter().position(|numeral| lower == *numeral))?;
    Some((u32::try_from(found).ok()? + 1, word.len()))
}

/// A day by full name, its plural or three-letter abbreviation, in any letter case: `(0 = Monday ..= 6 = Sunday, length)`.
///
/// PHP reads the word up to the next space or separator, whatever the characters, so `Tue*` is not a day.
pub(crate) fn day(text: &str) -> Option<(u32, usize)> {
    let end = text.find([' ', ',', '\t', ';', ':', '/', '.', '-', '(', ')']).unwrap_or(text.len());
    let word = &text[..end];
    let lower = word.to_ascii_lowercase();
    let found = DAYS.iter().position(|name| {
        let name = name.to_ascii_lowercase();
        lower == name || lower == name[..3] || lower.strip_suffix('s') == Some(&name)
    })?;
    Some((u32::try_from(found).ok()?, word.len()))
}

/// The English ordinal suffix of a day of the month.
pub(crate) const fn ordinal_suffix(day: u32) -> &'static str {
    if matches!(day, 11..=13) {
        return "th";
    }
    match day % 10 {
        1 => "st",
        2 => "nd",
        3 => "rd",
        _ => "th",
    }
}