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,8 +1,8 @@
|
||||
import json
|
||||
import re
|
||||
import sys
|
||||
from common import dates
|
||||
from common import endoflife
|
||||
from datetime import datetime
|
||||
|
||||
METHOD = "pypi"
|
||||
DEFAULT_TAG_TEMPLATE = ( # Same as used in Ruby (update.rb)
|
||||
@@ -27,7 +27,7 @@ def fetch_releases(pypi_id, regex):
|
||||
if re.match(r, version):
|
||||
matches = True
|
||||
if matches and R:
|
||||
d = datetime.fromisoformat(R[0]["upload_time"]).strftime("%Y-%m-%d")
|
||||
d = dates.parse_datetime(R[0]["upload_time"], to_utc=False).strftime("%Y-%m-%d")
|
||||
releases[version] = d
|
||||
print(f"{version}: {d}")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user