Commit acf43234 authored by Alexandre Teles's avatar Alexandre Teles Committed by GitHub

Fix strftime format string (#646)

* Fix strftime format string

Lines 28 and 29 that were using `.strftime('%s')` where it should be written as `.strftime('%S')`. This error would make twint fail with an `Invalid format string` when using time-related configurations like `Since` and `Until`.

* Change strftime to timestamp

As we are looking for the timestamp version of the provided date/time string, using `timestamp()` should be more straightforward and shouldn't create any incompatibility issues as twint already requires Python >= 3.6
parent e5d17b65
......@@ -35,8 +35,8 @@ def datecheck(datetimestamp, config):
logme.debug(__name__+':datecheck')
if config.Since and config.Until:
logme.debug(__name__+':datecheck:dateRangeTrue')
d = int(datetime.strptime(datetimestamp, "%Y-%m-%d %H:%M:%S").strftime('%s'))
s = int(datetime.strptime(config.Since, "%Y-%m-%d %H:%M:%S").strftime('%s'))
d = int(datetime.strptime(datetimestamp, "%Y-%m-%d %H:%M:%S").timestamp())
s = int(datetime.strptime(config.Since, "%Y-%m-%d %H:%M:%S").timestamp())
if d < s:
return False
logme.debug(__name__+':datecheck:dateRangeFalse')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment