awaitctx.send(f"Current system time: {time.strftime(fmt)}")
else:
fmt="**%H:%M** %d-%B-%Y **%Z (UTC %z)**"
if"'"intz:
tz=tz.replace("'","")
iflen(tz)>4and"/"notintz:
awaitctx.send(
"Error: Incorrect format. Use:\n **Continent/City** with correct capitals. e.g. `America/New_York`\n See the full list of supported timezones here:\n <https://en.wikipedia.org/wiki/List_of_tz_database_time_zones>"
)
else:
time=datetime.now(pytz.timezone(tz))
awaitctx.send(time.strftime(fmt))
exceptExceptionase:
awaitctx.send(f"**Error:** {str(e)} is an unsupported timezone.")
@time.command()
asyncdefiso(self,ctx,*,code):
"""Looks up ISO3166 country codes and gives you a supported timezone."""
ifcode=="":
awaitctx.send("That doesn't look like a country code!")
else:
ifcodeincountry_timezones:
exist=True
else:
exist=False
ifexist==True:
msg=f"Supported timezones for **{code}:**\n"
tz=str(country_timezones(code))
tz=tz[:-1]
tz=tz[1:]
msg+=tz
msg+=f"\n**Use** `[p]time tz Continent/City` **to display the current time in that timezone.**"
awaitctx.send(msg)
else:
awaitctx.send(
"That code isn't supported. For a full list, see here: <https://en.wikipedia.org/wiki/List_of_tz_database_time_zones>"