Skip to content

_parse_freshness_timedelta

Internal helper
This page documents an internal implementation helper, not a primary public API.
Source code in src/fabricops_kit/quality.py
1027
1028
1029
1030
1031
1032
1033
1034
def _parse_freshness_timedelta(value: str | None) -> timedelta | None:
    if not value:
        return None
    m = re.match(r"^\s*(\d+)\s*(day|days|hour|hours)\s*$", str(value).strip().lower())
    if not m:
        return None
    qty, unit = int(m.group(1)), m.group(2)
    return timedelta(days=qty) if unit.startswith("day") else timedelta(hours=qty)