Parse duration in the format '14d' or '24h'.
(value: str)
| 8 | |
| 9 | |
| 10 | def _parse_duration(value: str) -> timedelta: |
| 11 | """Parse duration in the format '14d' or '24h'.""" |
| 12 | if value.endswith("d"): |
| 13 | return timedelta(days=int(value[:-1])) |
| 14 | if value.endswith("h"): |
| 15 | return timedelta(hours=int(value[:-1])) |
| 16 | raise ValueError("Invalid duration format. Use Nd or Nh") |
| 17 | |
| 18 | |
| 19 | def _should_delete(record: dict[str, Any], threshold: datetime) -> bool: |