Skip to main content

parse_excluded_dates

Function parse_excluded_dates 

Source
pub fn parse_excluded_dates(
    raw: &str,
    on_rejected: impl FnMut(&str),
) -> Vec<String>
Expand description

The dates listed in an EXDATE value, normalised to YYYY-MM-DD.

Separators are commas and whitespace, in any mix — a list is written for a person to read, and both are what people write. The result keeps the order the value was written in and holds one entry per date, whichever way the value spelled it.

A time right after a date is that date’s time, not another field: RFC 5545 writes an EXDATE of a timed series that way, and so does a calendar export. It is read and left out — occurrences are matched by day here (ADR-0031) — while a time with no date before it is a field like any other and is rejected.

A field that does not parse is handed to on_rejected as it is met rather than collected: the value is only as short as the file makes it, and one written entirely of rubbish would otherwise be held twice over — once in the file, once in a vector — for a caller that reports the first few and drops the rest.