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:
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user