Skip to main content

render_date_code

Function render_date_code 

Source
pub fn render_date_code(
    date: SimpleDate,
    code: &str,
    month_case: StringCase,
) -> String
Expand description

Renders a date through an Excel number-format code.

Handles the date tokens visi recognizes: runs of y (1-2 -> 2-digit year, 3+ -> 4-digit), m (1 -> bare month, 2 -> zero-padded, 3 -> Jun, 4+ -> June) and d (1 -> bare day, 2+ -> zero-padded). Anything else is copied through verbatim, so separators and literal text survive.

Tokens are matched as runs in a single pass rather than by successive string replacement, which is what keeps a substituted month name from being re-scanned – December contains an m and May a y.