diff --git a/src/utils.py b/src/utils.py index 8bf6d56..d3d945b 100644 --- a/src/utils.py +++ b/src/utils.py @@ -70,6 +70,18 @@ def remove_patched_files(original_dir: pathlib.Path, override_dir: pathlib.Path) except BaseException as e: raise e +def extract_date(date_string: str): + """Extract a date in the format of 'd(d) Monthname yyyy'. + Returns a datetime object + """ + date_stripped = re.search(r"\d+ \w* \d+", date_string).group(0) + + locale.setlocale(locale.LC_TIME, "en_US") + date = time.strptime(date_stripped, "%d %B %Y") + locale.setlocale(locale.LC_TIME, "de_DE") + + return date + def check_dotnet(): """Checks if dotnet is available.""" return not (shutil.which("dotnet") is None)