import pytz


async def get_user_timezone(ctx, user):
    """
    Returns a pytz.timezone for a user if set, returns None otherwise
    """
    query = '''SELECT tz
               FROM timezones
               WHERE "user" = $1;'''
    record = await ctx.bot.pool.fetchrow(query, user.id)
    if record is None:
        return None
    else:
        return pytz.timezone(record.get('tz'))