summaryrefslogtreecommitdiff
path: root/src/common.py
diff options
context:
space:
mode:
authorlouiz@4325f9fc-e183-4c21-96ce-0ab188b42d13 <louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13>2010-03-19 03:30:51 +0000
committerlouiz@4325f9fc-e183-4c21-96ce-0ab188b42d13 <louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13>2010-03-19 03:30:51 +0000
commita923d32ee47fab1aa5de01a1c41a8082c108a649 (patch)
tree0f3248fb54f48a149bc71b43dbd7088da98f32b6 /src/common.py
parentd25f061a8bfc71317f045c6b78d98777cd871098 (diff)
downloadpoezio-a923d32ee47fab1aa5de01a1c41a8082c108a649.tar.gz
poezio-a923d32ee47fab1aa5de01a1c41a8082c108a649.tar.bz2
poezio-a923d32ee47fab1aa5de01a1c41a8082c108a649.tar.xz
poezio-a923d32ee47fab1aa5de01a1c41a8082c108a649.zip
fixed #1230 Do not put the 'there is a message' color when the message is from the MUC history
Diffstat (limited to 'src/common.py')
-rw-r--r--src/common.py18
1 files changed, 18 insertions, 0 deletions
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')