Skip to content

Commit

Permalink
Use pytz to add timezone info to the footer time in embed
Browse files Browse the repository at this point in the history
  • Loading branch information
yutotakano committed Jul 2, 2022
1 parent b8b3898 commit df0e91e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
4 changes: 3 additions & 1 deletion post_updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from typing import Any

import discord
import pytz

client = discord.Client()

Expand Down Expand Up @@ -45,8 +46,9 @@ async def post_or_update():
description="\n".join(post.split("\n")[1:]).strip(),
colour=int(get_actions_environ("EMBED_COLOR", '0'))
)
current_uk_time = atetime.datetime.now(tz=pytz.timezone('Europe/London'))
args["embed"].set_footer(
text=f"Last updated: {datetime.datetime.now().strftime('%a, %d %b %Y %H:%M:%S %Z')}"
text=f"Last updated: {current_uk_time.strftime('%a, %d %b %Y %H:%M:%S %Z')}"
)
else:
args["content"] = post
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
discord.py>=1.7.3
pytz>=2022.1

0 comments on commit df0e91e

Please sign in to comment.