diff --git a/lib/helpers.py b/lib/helpers.py index 0535c83..f1024b1 100644 --- a/lib/helpers.py +++ b/lib/helpers.py @@ -6,7 +6,7 @@ import re from dateconverter import * from datetime import datetime DEBUG = True - +number = ['0','1','2','3','4','5','6','7','8','9'] def log(*s): if DEBUG: print(s) @@ -190,3 +190,22 @@ def makeSession(url): with requests.Session() as session: page = session.get(url) return session +def indeedExtractDays(datestr): + cleannumstr='' + cleannumint=-1 + cleandate='' + foundchar=False + for a in datestr: + print(a) + if a in number and foundchar==False: + foundchar=True + cleannumstr+=a + elif a in number and foundchar == True: + cleannumstr+=a + elif a not in number and foundchar == True: + break + cleannumint = int(cleannumstr) + today = int(datetime.utcnow().timestamp()) + cleandate = today - cleannumint * 60 * 60 * 7 * 4 + #print("int:",cleannumint,"today:",today,"cleandate:",datetime.fromtimestamp(cleandate).strftime('%Y-%m-%d')) + return datetime.fromtimestamp(cleandate).strftime('%Y-%m-%d')