I am creating simple RSS reader. Storing date of last read newest entry in newest_entry_datetime
and then when reading again channel I am comparing entry time to newest_entry_datetime
with <
symbol as I read that Python is smart enough to recognize and compare datetime.
It works on the same day when time part is changing but on the next day newest date is implemented as old.
import datetime
import locale
#locale.setlocale(locale.LC_ALL, 'English_United States.1252')
newest_entry_datetime = 'Thu, 21 Dec 2017 16:02:03 CET'
entry_published = 'Fri, 22 Dec 2017 08:19:15 CET'
#dt_newest = datetime.datetime.strptime (newest_entry_datetime, "%a, %d %b %Y %H:%M:%S %Z" )
if (entry_published <= newest_entry_datetime):
print('Entry date is older')
else:
print('Entry date is NEW')
With such code I am getting result: "Entry date is older"
which is wrong.
Second idea was to convert datestamps to datetime but I am getting:
ValueError: time data 'Thu, 21 Dec 2017 16:02:03 CET' does not match format '%a, %d %b %Y %H:%M:%S %Z'
even if I will change locale to US.
No clue how to do that correctly. Could you please help?