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,6 +1,6 @@
import datetime
import re
from bs4 import BeautifulSoup
from common import dates
from common import endoflife
URLS = [
@@ -46,10 +46,9 @@ CONFIG = {
}
def parse_date(s):
d, m, y = s.strip().split(" ")
m = m[0:3].lower() # reduce months to 3 letters, such as "Sept" to "Sep", so it can be parsed
return datetime.datetime.strptime(f"{d} {m} {y}", "%d %b %Y")
def parse_date(date_str):
date_str = date_str.replace("Sept", "Sep")
return dates.parse_date(date_str)
print("::group::apple")