Skip to content

Commit

Permalink
Add UTC offset to ?timezone info
Browse files Browse the repository at this point in the history
  • Loading branch information
Rapptz committed Jun 8, 2023
1 parent 75c4cd9 commit 4a86f6b
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions cogs/reminder.py
Original file line number Diff line number Diff line change
Expand Up @@ -710,9 +710,17 @@ async def timezone_set(self, ctx: Context, *, tz: TimeZone):
async def timezone_info(self, ctx: Context, *, tz: TimeZone):
"""Retrieves info about a timezone."""

embed = discord.Embed(title='Current Time', colour=discord.Colour.blurple())
embed.description = discord.utils.utcnow().astimezone(dateutil.tz.gettz(tz.key)).strftime('%Y-%m-%d %I:%M %p')
embed.add_field(name='IANA ID', value=tz.key)
embed = discord.Embed(title=tz.key, colour=discord.Colour.blurple())
dt = discord.utils.utcnow().astimezone(dateutil.tz.gettz(tz.key))
time = dt.strftime('%Y-%m-%d %I:%M %p')
embed.add_field(name='Current Time', value=time)

offset = dt.utcoffset()
if offset is not None:
minutes, _ = divmod(int(offset.total_seconds()), 60)
hours, minutes = divmod(minutes, 60)
embed.add_field(name='UTC Offset', value=f'{hours:+03d}:{minutes:02d}')

await ctx.send(embed=embed)

@timezone_set.autocomplete('tz')
Expand Down

0 comments on commit 4a86f6b

Please sign in to comment.