import arrow
import discord
from discord.ext import commands
from dog import Cog


class Time(Cog):
    @commands.group()
    async def time(self, ctx):
        """ Time-related commands. """
        if ctx.invoked_subcommand is None:
            await ctx.send('You must specify a valid subcommand to run. For help, run `d?help time`.')

    @time.command(name='in')
    async def time_in(self, ctx, *, timezone):
        """
        Views time in a timezone.

        List of valid timezone specifiers: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
        The "TZ" column is what you want. You can also specify a UTC offset.
        """
        try:
            time = arrow.utcnow().to(timezone)
            await ctx.send(time.format('YYYY-MM-DD (MMM, ddd) HH:mm:ss (hh:mm:ss A) ZZ'))
        except arrow.parser.ParserError:
            await ctx.send('Invalid timezone.')

    @time.command(name='tzdifference', aliases=['tzdiff', 'tzd'])
    async def time_tzdifference(self, ctx, a, b):
        """
        Views the difference between two timezones.
        """
        try:
            a_u = arrow.now(a).utcoffset()
            b_u = arrow.now(b).utcoffset()
            if a_u == b_u:
                return await ctx.send(f'{a} and {b} have the **same UTC offset.**')
            diff = max(a_u, b_u) - min(a_u, b_u)
            await ctx.send(f'{a} and {b} are **{diff}** apart.')
        except arrow.parser.ParserError:
            await ctx.send('Parsing error. Typically, this means your timezones were invalid.')


def setup(bot):
    bot.add_cog(Time(bot))

@@ -10,23 +10,8 @@
 row%0A
-import discord%0A
 from
@@ -26,24 +26,31 @@
 .ext
- import commands
+.commands import group%0A
 %0Afro
@@ -90,25 +90,16 @@
 ):%0A    @
-commands.
 group()%0A
@@ -238,16 +238,17 @@
 tx.send(
+f
 'You mus
@@ -299,17 +299,28 @@
 p, run %60
-d
+%7Bctx.prefix%7D
 ?help ti

clean up time cog