def _to_local_timezone(self, messages, tzoffset): tzoffset = iso8601.FixedOffset(0, int(tzoffset), "") for key in messages.keys(): for mtuple in messages[key]: # Change message times to local timezone olddate = iso8601.parse_date(mtuple[2]) date = (olddate + tzoffset.offset).replace(tzinfo=tzoffset) mtuple[2] = date.isoformat() return messages
def get_html_formatted_messages(username, messages): """ """ lines = [] for m in messages: date = iso8601.parse_date(m[2]).strftime('%Y-%m-%d %H:%M') if m[0] != username: line = \ '<div class="chat-message">' + \ '<span class="chat-message-them">'+date+' '+m[3]+': </span>' + \ '<span class="chat-message-content">'+m[1]+'</span>' + \ '</div>' else: line = \ '<div class="chat-message">' + \ '<span class="chat-message-me">'+date+' me: </span>' + \ '<span class="chat-message-content">'+m[1]+'</span>' + \ '</div>' lines.append(line) return ''.join(lines)