MCPcopy Create free account
hub / github.com/acking-you/static_flow / normalize_cli_date

Function normalize_cli_date

crates/cli/src/commands/write_article.rs:876–888  ·  view source on GitHub ↗
(date: Option<String>)

Source from the content-addressed store, hash-verified

874}
875
876fn normalize_cli_date(date: Option<String>) -> Result<Option<String>> {
877 let Some(date) = date else {
878 return Ok(None);
879 };
880 let date = date.trim();
881 if date.is_empty() {
882 return Ok(None);
883 }
884
885 chrono::NaiveDate::parse_from_str(date, "%Y-%m-%d")
886 .with_context(|| format!("invalid --date `{date}`; expected YYYY-MM-DD"))?;
887 Ok(Some(date.to_string()))
888}
889
890#[cfg(test)]
891mod tests {

Calls 3

trimMethod · 0.80
is_emptyMethod · 0.45
with_contextMethod · 0.45