VickiLanger / LGBTQ-of-the-day-bot

Twitter bot tweeting fun goofy lgbtq things and queer history of the day
https://twitter.com/LGBTQotd
GNU General Public License v3.0
80 stars 173 forks source link

Incorrect Event Date Posted #297

Closed VickiLanger closed 2 years ago

VickiLanger commented 3 years ago

Describe the bug An event for 2004-07-20 will post on 04-07 and 07-20

https://twitter.com/lgbtqotd/status/1379660512082944002?s=21

Expected behavior Only have post on the correct date

Screenshots Screenshot of faulty tweet, posted on April 7th, with the above-described bug "17 years ago this day in LGBTQ history 2004-07-20: Guido Westerwelle, leader of the FDP, becomes the first leader of a major party to come out."


Don't forget to follow the bot on Twitter to see the hard work you put in.

VickiLanger commented 3 years ago

This doesn't make sense. We already get rid of the year. So, why did this event post when it did?

    # get today's date
    today = str(date.today())

    # extract month and day
    month_and_day = today[5:]  # slice off the first 5 characters

    # make a list of the events that match month_and_day
    list_of_history_tweets = [key + ":\n" + val for key, val in events.items() if month_and_day in key]
    length_list_history_tweets = len(list_of_history_tweets)
JasirZaeem commented 3 years ago

This is searching for MM-DD in each key, and each key is YYYY-MM-DD, so, if the key for an event is '2004-07-20', on 7th April code will match it with '04-07' which is present in the date, and on 20th July it'll be checked against '07-20' which it also has. the MM-DD for today needs to be matched with only the last 5 characters of the date not all of it. I'll make a pr with a fix

VickiLanger commented 3 years ago

This is searching for MM-DD in each key, and each key is YYYY-MM-DD, so, if the key for an event is '2004-07-20', on 7th April code will match it with '04-07' which is present in the date, and on 20th July it'll be checked against '07-20' which it also has. the MM-DD for today needs to be matched with only the last 5 characters of the date not all of it. I'll make a pr with a fix

That would be awesome. I'm still confused though. I thought we already sliced the first 5 characters in the date. 🤷🏼

JasirZaeem commented 3 years ago

We are removing the first 5 letters of today's date but the dates of events are still in "YYYY-MM-DD" format, so we need to compare the variable month_and_day with only the last 5 letters of the keys

geekboi777 commented 3 years ago

Hey I made a pull request resolving the issue.

Hope it helps!