Simplify date parsing (#195)

Create common functions parse_date, parse_month_year_date and parse_datetime.

Those functions support trying multiple formats, and come with default formats lists that support most of the date format encountered so far.

Notable change: year-month dates are now set to the end of month (impacted couchbase-server and ibm-aix).
This commit is contained in:
Marc Wrobel
2023-11-26 21:01:35 +01:00
committed by GitHub
parent 1e65a048b0
commit 0d17306872
24 changed files with 133 additions and 168 deletions

View File

@@ -1,7 +1,7 @@
import re
from bs4 import BeautifulSoup
from common import dates
from common import endoflife
from datetime import datetime
"""Fetch versions with their dates from docs.couchbase.com.
@@ -46,7 +46,7 @@ for response in endoflife.fetch_urls(minor_version_urls):
m = re.match(REGEX, versionAndDate)
if m:
version = f"{m['version']}.0" if len(m['version'].split('.')) == 2 else m['version']
date = datetime.strptime(m['date'], "%B %Y").strftime("%Y-%m-15")
date = dates.parse_month_year_date(m['date']).strftime("%Y-%m-%d")
versions[version] = date
print(f"{version}: {date}")