UPDATE Enable parsing of yaml datetime value without error

- ADD parse_datetime helper function to parse datetime or isoformat string to datetime
This commit is contained in:
Jeppy
2022-11-05 18:36:10 +01:00
committed by Sebastian Thomschke
parent 5363fdb087
commit 01803c525c
2 changed files with 20 additions and 3 deletions

View File

@@ -19,7 +19,7 @@ from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from . import utils, resources, extract # pylint: disable=W0406
from .utils import abspath, apply_defaults, ensure, is_frozen, pause, pluralize, safe_get
from .utils import abspath, apply_defaults, ensure, is_frozen, pause, pluralize, safe_get, parse_datetime
from .selenium_mixin import SeleniumMixin
# W0406: possibly a bug, see https://github.com/PyCQA/pylint/issues/3933
@@ -256,9 +256,9 @@ class KleinanzeigenBot(SeleniumMixin):
if self.ads_selector == "due":
if ad_cfg["updated_on"]:
last_updated_on = datetime.fromisoformat(ad_cfg["updated_on"])
last_updated_on = parse_datetime(ad_cfg["updated_on"])
elif ad_cfg["created_on"]:
last_updated_on = datetime.fromisoformat(ad_cfg["created_on"])
last_updated_on = parse_datetime(ad_cfg["created_on"])
else:
last_updated_on = None