Skip to content

Commit

Permalink
Addon Manager: Fix for Py3.6 w/ no fromisodate
Browse files Browse the repository at this point in the history
  • Loading branch information
chennes committed Jan 11, 2022
1 parent 5ee5a6e commit 70d61b9
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/Mod/AddonManager/AddonManager.py
Expand Up @@ -258,7 +258,13 @@ def launch(self) -> None:
if last_cache_update_string == "never":
self.update_cache = True
elif days_between_updates > 0:
last_cache_update = date.fromisoformat(last_cache_update_string)
if hasattr(date, "fromisoformat"):
last_cache_update = date.fromisoformat(last_cache_update_string)
else:
# Python 3.6 and earlier don't have date.fromisoformat
date_re = re.compile("([0-9]{4})-?(1[0-2]|0[1-9])-?(3[01]|0[1-9]|[12][0-9])")
matches = date_re.match (last_cache_update_string)
last_cache_update = date(int(matches.group(1)),int(matches.group(2)),int(matches.group(3)))
delta_update = timedelta(days=days_between_updates)
if date.today() >= last_cache_update + delta_update:
self.update_cache = True
Expand Down

0 comments on commit 70d61b9

Please sign in to comment.