# Path: txircd/utils.py
# def epoch(utc_datetime):
#     delta = utc_datetime - UNIX_EPOCH
#     return int(delta.total_seconds())
# 
# def now():
#     return datetime.datetime.utcnow().replace(microsecond=0)


from twisted.words.protocols import irc
from txircd.utils import epoch, now
from copy import deepcopy
        from txircd.server import ChannelMessage
            from txircd.server import SetMode
        from txircd.server import SetTopic
        from txircd.server import SetMetadata # This import is moved to here to alleviate issues with circular dependencies
        from txircd.server import SetMetadata
                    adding = "+"
                    modestring.append("+")
                elif not mode[0] and adding != "-":
                    adding = "-"
                    modestring.append("-")
                modestring.append(mode[1])
                if mode[2]:
                    showParams.append(mode[2])
            modeLine = "{} {}".format("".join(modestring), " ".join(showParams)) if showParams else "".join(modestring)
            if user:
                for u in self.users.iterkeys():
                    u.sendMessage("MODE", modeLine, to=self.name, prefix=user.prefix())
                lineSource = user.prefix()
            elif displayPrefix:
                for u in self.users.iterkeys():
                    u.sendMessage("MODE", modeLine, to=self.name, prefix=displayPrefix)
                lineSource = displayPrefix
            else:
                for u in self.users.iterkeys():
                    u.sendMessage("MODE", modeLine, to=self.name)
                lineSource = self.ircd.name
            
            for server in self.ircd.servers.itervalues():
                if server.nearHop == self.ircd.name:
                    server.callRemote(SetMode, target=self.name, targetts=epoch(self.created), source=lineSource, modestring="".join(modestring), params=showParams)
            for action in self.ircd.actions["mode"]:
                action(self, lineSource, modeLine, modeDisplay)
            return modeLine
        return ""
    

# Path: txircd/utils.py
# def epoch(utc_datetime):
#     delta = utc_datetime - UNIX_EPOCH
#     return int(delta.total_seconds())
# 
# def now():
#     return datetime.datetime.utcnow().replace(microsecond=0)


# Path: txircd/channel.py
from twisted.words.protocols import irc
from txircd.utils import epoch, now
from copy import deepcopy
        from txircd.server import ChannelMessage
            from txircd.server import SetMode
        from txircd.server import SetTopic
        from txircd.server import SetMetadata # This import is moved to here to alleviate issues with circular dependencies
        from txircd.server import SetMetadata

                    adding = "+"
                    modestring.append("+")
                elif not mode[0] and adding != "-":
                    adding = "-"
                    modestring.append("-")
                modestring.append(mode[1])
                if mode[2]:
                    showParams.append(mode[2])
            modeLine = "{} {}".format("".join(modestring), " ".join(showParams)) if showParams else "".join(modestring)
            if user:
                for u in self.users.iterkeys():
                    u.sendMessage("MODE", modeLine, to=self.name, prefix=user.prefix())
                lineSource = user.prefix()
            elif displayPrefix:
                for u in self.users.iterkeys():
                    u.sendMessage("MODE", modeLine, to=self.name, prefix=displayPrefix)
                lineSource = displayPrefix
            else:
                for u in self.users.iterkeys():
                    u.sendMessage("MODE", modeLine, to=self.name)
                lineSource = self.ircd.name
            
            for server in self.ircd.servers.itervalues():
                if server.nearHop == self.ircd.name:
                    server.callRemote(SetMode, target=self.name, targetts=epoch(self.created), source=lineSource, modestring="".join(modestring), params=showParams)
            for action in self.ircd.actions["mode"]:
                action(self, lineSource, modeLine, modeDisplay)
            return modeLine
        return ""
    

    def modeString(self, user):