From 93351156a122dd7e374778c1c838b5c4c1dda83d Mon Sep 17 00:00:00 2001 From: "louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13" Date: Wed, 14 Jul 2010 18:26:01 +0000 Subject: [PATCH] history time is now correct. fixed #1571 --- src/common.py | 12 +++++++----- src/gui.py | 3 +-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/common.py b/src/common.py index 3edc9e14..4406e4cb 100644 --- a/src/common.py +++ b/src/common.py @@ -33,7 +33,7 @@ """ various useful functions """ - +from datetime import datetime, timedelta import base64 import os import mimetypes @@ -44,6 +44,7 @@ import sys import select import errno import xmpp +import time def debug(string): """ @@ -261,7 +262,8 @@ def datetime_tuple(timestamp): """ 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') + ret = datetime.strptime(timestamp, '%Y%m%dT%H:%M:%SZ') + # convert UTC to local time, with DST etc. + dst = timedelta(seconds=time.altzone) + ret -= dst + return ret diff --git a/src/gui.py b/src/gui.py index 4e05d5d7..96f27907 100644 --- a/src/gui.py +++ b/src/gui.py @@ -377,8 +377,7 @@ class Gui(object): """ Display the message on the room window """ - delay_tag = stanza.getTag('delay', namespace='urn:xmpp:delay') - if delay_tag and not date: + if delay_tag: delayed = True date = common.datetime_tuple(delay_tag.getAttr('stamp')) else: