mirror of https://gitlab.com/bashrc2/epicyon
Snake case
parent
4215af54e3
commit
f586d1bf66
16
utils.py
16
utils.py
|
@ -211,16 +211,16 @@ def has_users_path(path_str: str) -> bool:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def valid_post_date(published: str, maxAgeDays: int, debug: bool) -> bool:
|
def valid_post_date(published: str, max_age_days: int, debug: bool) -> bool:
|
||||||
"""Returns true if the published date is recent and is not in the future
|
"""Returns true if the published date is recent and is not in the future
|
||||||
"""
|
"""
|
||||||
baselineTime = datetime.datetime(1970, 1, 1)
|
baseline_time = datetime.datetime(1970, 1, 1)
|
||||||
|
|
||||||
daysDiff = datetime.datetime.utcnow() - baselineTime
|
daysDiff = datetime.datetime.utcnow() - baseline_time
|
||||||
nowDaysSinceEpoch = daysDiff.days
|
now_days_since_epoch = daysDiff.days
|
||||||
|
|
||||||
try:
|
try:
|
||||||
postTimeObject = \
|
post_time_object = \
|
||||||
datetime.datetime.strptime(published, "%Y-%m-%dT%H:%M:%SZ")
|
datetime.datetime.strptime(published, "%Y-%m-%dT%H:%M:%SZ")
|
||||||
except BaseException:
|
except BaseException:
|
||||||
if debug:
|
if debug:
|
||||||
|
@ -228,15 +228,15 @@ def valid_post_date(published: str, maxAgeDays: int, debug: bool) -> bool:
|
||||||
str(published))
|
str(published))
|
||||||
return False
|
return False
|
||||||
|
|
||||||
daysDiff = postTimeObject - baselineTime
|
daysDiff = post_time_object - baseline_time
|
||||||
postDaysSinceEpoch = daysDiff.days
|
postDaysSinceEpoch = daysDiff.days
|
||||||
|
|
||||||
if postDaysSinceEpoch > nowDaysSinceEpoch:
|
if postDaysSinceEpoch > now_days_since_epoch:
|
||||||
if debug:
|
if debug:
|
||||||
print("Inbox post has a published date in the future!")
|
print("Inbox post has a published date in the future!")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if nowDaysSinceEpoch - postDaysSinceEpoch >= maxAgeDays:
|
if now_days_since_epoch - postDaysSinceEpoch >= max_age_days:
|
||||||
if debug:
|
if debug:
|
||||||
print("Inbox post is not recent enough")
|
print("Inbox post is not recent enough")
|
||||||
return False
|
return False
|
||||||
|
|
Loading…
Reference in New Issue