in psaw/utilities.py [0:0]
def string_to_epoch(s):
"""
Convert argument string to epoch if possible
If argument looks like int + s,h,md (ie, 30d), we'll pass as-is
since pushshift can accept this. Per docs, pushshift supports:
Epoch value or Integer + "s,m,h,d" (i.e. 30d for 30 days)
:param s: str
:return: int | str
"""
if s is not None:
s = s.strip()
if re.search('^[0-9]+[smhd]$', s):
return s
try:
s = dp.parse(s).timestamp()
s = int(s)
except ValueError:
raise click.BadParameter("could not convert argument to "
"a datetime: {}".format(s))
return s