[version_table] Improve date parsing (#527)

So far the script only allowed datetimes. Now full/partial dates are allowed too.
This commit is contained in:
Marc Wrobel
2025-11-08 13:18:14 +01:00
committed by GitHub
parent 03905bcf79
commit 1fb86114be
3 changed files with 13 additions and 7 deletions

View File

@@ -138,16 +138,13 @@ class Field:
str_value = self.template.render(**match.groupdict()) if self.template else raw_value
if self.type == "date":
try:
return dates.parse_date(str_value)
except ValueError:
return dates.parse_month_year_date(str_value)
return dates.parse_date_or_month_year_date(str_value)
elif self.type == "range":
if self.type == "range":
items = RANGE_LIST_SEPARATOR_PATTERN.split(str_value)
return f"{items[0]} - {items[-1]}" if len(items) > 1 else str_value
elif self.type == "identifier":
if self.type == "identifier":
return endoflife.to_identifier(str_value)
return str_value