assets_guardian.utils.datesο
Functions
|
Replaces the 'DATE' placeholder in the filename with today's date, if present. |
|
Formats a date into a string for display. |
|
Parses a value into a datetime. |
- assets_guardian.utils.dates.add_date_to_filename(path: str | Path, date_format: str = '%Y_%m_%d') str[source]ο
Replaces the βDATEβ placeholder in the filename with todayβs date, if present.
- Parameters:
path β Original file path (e.g. βoutputs/audit_report_DATE.pdfβ).
date_format β strftime format used for the date.
- Returns:
- The path with βDATEβ replaced by todayβs date (e.g.
βoutputs/audit_report_2026_07_08.pdfβ), or unchanged if the filename has no βDATEβ placeholder (e.g. βoutputs/audit_report.pdfβ).
- Return type:
str
- assets_guardian.utils.dates.format_datetime(value: datetime | str | None) str[source]ο
Formats a date into a string for display.
Returns βNeverβ if the date is None or invalid. If a string is passed, tries to parse it first.
- Parameters:
value β The date to format (datetime, str, or None).
- Returns:
The formatted date or βNeverβ.
- Return type:
str