From a923d32ee47fab1aa5de01a1c41a8082c108a649 Mon Sep 17 00:00:00 2001 From: "louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13" Date: Fri, 19 Mar 2010 03:30:51 +0000 Subject: fixed #1230 Do not put the 'there is a message' color when the message is from the MUC history --- src/common.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/common.py') diff --git a/src/common.py b/src/common.py index 421aada2..340eb213 100644 --- a/src/common.py +++ b/src/common.py @@ -186,3 +186,21 @@ def get_os_info(): return os_info os_info = 'N/A' return os_info + +def datetime_tuple(timestamp): + """ + Convert timestamp using strptime and the format: %Y%m%dT%H:%M:%S + + Because of various datetime formats are used the following exceptions + are handled: + - Optional milliseconds appened to the string are removed + - Optional Z (that means UTC) appened to the string are removed + - XEP-082 datetime strings have all '-' cahrs removed to meet + the above format. + """ + timestamp = timestamp.split('.')[0] + timestamp = timestamp.replace('-', '') + timestamp = timestamp.replace('z', '') + timestamp = timestamp.replace('Z', '') + from datetime import datetime + return datetime.strptime(timestamp, '%Y%m%dT%H:%M:%S') -- cgit v1.2.3