def html_chat_time(self, msgtime):
        """Return formatted time with colors."""
        option = 'weechat.look.buffer_time_format'
        if self.options[option].find('${') >= 0:
            str_without_colors = re.sub(r'\$\{[^\}]+\}', '', self.options[option])
            length = len(time.strftime(str_without_colors, msgtime))
            value = re.compile(r'\$\{[^\}]+\}[^\$]*').sub(self._html_apply_colors, self.options[option])
        else:
            value = time.strftime(self.options[option], msgtime)
            length = len(value)
            value = re.compile(r'[^0-9]+').sub(self._html_apply_color_chat_time_delimiters, value)
            value = self.html_string(value, 0, 'weechat.color.chat_time')
        return (time.strftime(value, msgtime), length)