Skip to content

Commit

Permalink
improve datetime handling a tiny bit
Browse files Browse the repository at this point in the history
  • Loading branch information
ueffel committed Feb 7, 2023
1 parent 1c51fc4 commit 8a06d8f
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions packagecontrol.py
Original file line number Diff line number Diff line change
Expand Up @@ -490,17 +490,20 @@ def _get_available_packages(self, force=False):
finally:
self.__list_updating = False

def _make_date(self, date_str):
def _make_date(self, date):
"""Parses a isoformat datetime string to an datetime-object
Don't look at this, just don't
"""
if re.search(r"[+\-]\d\d:\d\d$", date_str):
date_str = date_str[:-3] + date_str[-2:]
elif date_str[-5] != '-' and date_str[-5] != '+':
date_str += "+0000"
if isinstance(date, datetime.datetime):
return date

return datetime.datetime.strptime(date_str, "%Y-%m-%dT%H:%M:%S%z")
if re.search(r"[+\-]\d\d:\d\d$", date):
date = date[:-3] + date[-2:]
elif date[-5] != '-' and date[-5] != '+':
date += "+0000"

return datetime.datetime.strptime(date, "%Y-%m-%dT%H:%M:%S%z")

def _get_last_run(self):
"""Reads the time of the last run from file
Expand Down

0 comments on commit 8a06d8f

Please sign in to comment.