Commit 5d853e90 authored by André's avatar André Committed by Philipp Hörist
Browse files

Time: use classes from standard library

parent e128a3f6
......@@ -25,8 +25,6 @@ from import NetworkIncomingEvent
log = logging.getLogger('gajim.c.m.entity_time')
ZERO = datetime.timedelta(0)
class EntityTime:
def __init__(self, con):
......@@ -79,7 +77,7 @@ class EntityTime:
tzo = '0:0'
tzoh, tzom = tzo.split(':')
except Exception as e:
except Exception:
log.warning('Wrong tzo node: %s', stanza)
utc_time = time_.getTag('utc').getData()
......@@ -106,8 +104,11 @@ class EntityTime:
e, stanza.getFrom())
t = t.replace(tzinfo=UTC())
return t.astimezone(contact_tz(tzoh, tzom)).strftime('%c')
utc = datetime.timezone(datetime.timedelta(0))
t = t.replace(tzinfo=utc)
utc_offset = datetime.timedelta(hours=int(tzoh), minutes=int(tzom))
contact_tz = datetime.timezone(utc_offset, "remote timezone")
return t.astimezone(contact_tz).strftime('%c')
def _answer_request(self, con, stanza):'%s asked for the time', stanza.getFrom())
......@@ -138,33 +139,5 @@ class TimeResultReceivedEvent(NetworkIncomingEvent):
return True
class UTC(datetime.tzinfo):
def utcoffset(self, dt):
return ZERO
def tzname(self, dt):
return "UTC"
def dst(self, dt):
return ZERO
class contact_tz(datetime.tzinfo):
def __init__(self, tzoh, tzom):
self._tzoh = tzoh
self._tzom = tzom
def utcoffset(self, dt):
return datetime.timedelta(hours=int(self._tzoh),
def tzname(self, dt):
return "remote timezone"
def dst(self, dt):
return ZERO
def get_instance(*args, **kwargs):
return EntityTime(*args, **kwargs), 'EntityTime'
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment