countdown-bot

A Discord bot that runs countdown games and generates analytics
git clone https://git.ashermorgan.net/countdown-bot/
Log | Files | Refs | README

commit bbc7e2fe3432f39a214a83f03458f8ed92c7b6ea
parent 617cf0e2619c77a745bdb2fc431248bec207575c
Author: AsherMorgan <59518073+AsherMorgan@users.noreply.github.com>
Date:   Sat, 23 Jan 2021 11:30:40 -0800

Fix timezone issues in progress graph.

Diffstat:
Mbot.py | 10+++++-----
1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/bot.py b/bot.py @@ -327,7 +327,7 @@ async def progress(ctx): plt.gcf().autofmt_xdate() # Add data to graph - x = [stats['start']] + [x["time"] for x in stats["progress"]] + x = [stats["start"] + timedelta(hours=TIMEZONE)] + [x["time"] + timedelta(hours=TIMEZONE) for x in stats["progress"]] y = [0] + [x["progress"] for x in stats["progress"]] plt.plot(x, y) @@ -336,10 +336,10 @@ async def progress(ctx): file = discord.File(tmp.name, filename="image.png") # Calculate embed data - start = (stats['start'] + timedelta(hours=TIMEZONE)).date() - startDiff = (datetime.utcnow() - stats['start']).days - end = (stats['eta'] + timedelta(hours=TIMEZONE)).date() - endDiff = (stats['eta'] - datetime.utcnow()).days + start = (stats["start"] + timedelta(hours=TIMEZONE)).date() + startDiff = (datetime.utcnow() - stats["start"]).days + end = (stats["eta"] + timedelta(hours=TIMEZONE)).date() + endDiff = (stats["eta"] - datetime.utcnow()).days if endDiff < 0: endDiff = 0 # Create embed