From a0d752b3ab84d248f7188ac0ae40aebc61ef7a35 Mon Sep 17 00:00:00 2001 From: Yann Leboulanger Date: Sun, 7 Sep 2014 21:51:06 +0200 Subject: [PATCH] [fschmaus] Improve XEP-0082 support. Fixes #7814 --- src/common/connection_handlers_events.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/common/connection_handlers_events.py b/src/common/connection_handlers_events.py index 90b0f13d3..08eb74296 100644 --- a/src/common/connection_handlers_events.py +++ b/src/common/connection_handlers_events.py @@ -220,12 +220,21 @@ class TimeResultReceivedEvent(nec.NetworkIncomingEvent, HelperEvent): def dst(self, dt): return ZERO + if utc_time[-1:] == 'Z': + # Remove the trailing 'Z' + utc_time = utc_time[:-1] + elif utc_time[-6:] == "+00:00": + # Remove the trailing "+00:00" + utc_time = utc_time[:-6] + else: + log.info("Wrong timezone defintion: %s" % str(e)) + return try: - t = datetime.datetime.strptime(utc_time, '%Y-%m-%dT%H:%M:%SZ') + t = datetime.datetime.strptime(utc_time, '%Y-%m-%dT%H:%M:%S') except ValueError: try: t = datetime.datetime.strptime(utc_time, - '%Y-%m-%dT%H:%M:%S.%fZ') + '%Y-%m-%dT%H:%M:%S.%f') except ValueError as e: log.info('Wrong time format: %s' % str(e)) return