From c79f871bc45e048c71c3eeae76d747cecf4a1340 Mon Sep 17 00:00:00 2001 From: Marc Wrobel Date: Sat, 8 Feb 2025 17:10:53 +0100 Subject: [PATCH] [eks] Update script to accept month-year dates (#408) Some were spotted in the latest runs, see https://github.com/endoflife-date/release-data/actions/runs/13215761680. --- src/common/dates.py | 9 +++++++++ src/eks.py | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/common/dates.py b/src/common/dates.py index c24c2fe7..e2e1fbe4 100644 --- a/src/common/dates.py +++ b/src/common/dates.py @@ -36,6 +36,15 @@ def parse_month_year_date(text: str, formats: list[str] = frozenset([ return date.replace(day=last_day) +def parse_date_or_month_year_date(text: str) -> datetime: + """Parse a given text representing a date or a partial date using the default list of formats. + """ + try: + return parse_date(text) + except ValueError: + return parse_month_year_date(text) + + def parse_datetime(text: str, formats: list[str] = frozenset([ "%Y-%m-%d %H:%M:%S", # 2023-05-01 08:32:34 "%Y-%m-%dT%H:%M:%S", # 2023-05-01T08:32:34 diff --git a/src/eks.py b/src/eks.py index 0d2ff3db..c1303434 100644 --- a/src/eks.py +++ b/src/eks.py @@ -27,7 +27,7 @@ with releasedata.ProductData("eks") as product_data: k8s_version_match = endoflife.DEFAULT_VERSION_PATTERN.match(k8s_version) if k8s_version_match: - date = dates.parse_date(date_str) + date = dates.parse_date_or_month_year_date(date_str) # K8S patch version is not kept to match versions on https://github.com/aws/eks-distro/tags. version = f"{k8s_version_match.group('major')}.{k8s_version_match.group('minor')}-{eks_version.replace('.', '-')}" product_data.declare_version(version, date)