use crate::{
ClassifiedDate, DateClassification, DateToken, Dt, Lang, classify_date,
generate_unambiguous_candidates, try_compatible_formats,
};
use alloc::string::ToString;
#[inline]
pub(crate) fn is_week_date_missing_weekday(cls: &DateClassification) -> bool {
cls.has_w && cls.num_hyphen == 1 && matches!(cls.tokens.first(), Some(DateToken::Digits(n)) if *n >= 4)
}
pub(crate) fn parse_week_date_no_weekday(
normalized: &str,
lang: Lang,
ref_time: &Option<Dt>,
) -> Option<Dt> {
let w_pos = normalized.find("-W")?;
let mut normalized = normalized.to_string();
let week_end = w_pos + 4; if week_end <= normalized.len() {
let after = &normalized[week_end..];
if after.is_empty() || after.starts_with(' ') || after.starts_with('T') {
normalized.insert_str(week_end, "-1");
}
}
let classification = classify_date(&normalized.to_ascii_lowercase(), lang, ref_time).ok()?;
match classification {
ClassifiedDate::Cls(cls) => {
try_compatible_formats(&cls.date, generate_unambiguous_candidates(&cls))
}
_ => None,
}
}