XEP-0202: Remove usage of mini_dateutil
Like the previous commit, we now use the builtin datetime module always.
This commit is contained in:
parent
fc63768cfc
commit
78a5f79240
@ -8,7 +8,6 @@ import datetime as dt
|
|||||||
|
|
||||||
from slixmpp.xmlstream import ElementBase
|
from slixmpp.xmlstream import ElementBase
|
||||||
from slixmpp.plugins import xep_0082
|
from slixmpp.plugins import xep_0082
|
||||||
from slixmpp.thirdparty import tzutc, tzoffset
|
|
||||||
|
|
||||||
|
|
||||||
class EntityTime(ElementBase):
|
class EntityTime(ElementBase):
|
||||||
@ -87,7 +86,7 @@ class EntityTime(ElementBase):
|
|||||||
seconds (positive or negative) to offset.
|
seconds (positive or negative) to offset.
|
||||||
"""
|
"""
|
||||||
time = xep_0082.time(offset=value)
|
time = xep_0082.time(offset=value)
|
||||||
if xep_0082.parse(time).tzinfo == tzutc():
|
if xep_0082.parse(time).tzinfo == dt.timezone.utc:
|
||||||
self._set_sub_text('tzo', 'Z')
|
self._set_sub_text('tzo', 'Z')
|
||||||
else:
|
else:
|
||||||
self._set_sub_text('tzo', time[-6:])
|
self._set_sub_text('tzo', time[-6:])
|
||||||
@ -111,6 +110,6 @@ class EntityTime(ElementBase):
|
|||||||
date = value
|
date = value
|
||||||
if not isinstance(value, dt.datetime):
|
if not isinstance(value, dt.datetime):
|
||||||
date = xep_0082.parse(value)
|
date = xep_0082.parse(value)
|
||||||
date = date.astimezone(tzutc())
|
date = date.astimezone(dt.timezone.utc)
|
||||||
value = xep_0082.format_datetime(date)
|
value = xep_0082.format_datetime(date)
|
||||||
self._set_sub_text('utc', value)
|
self._set_sub_text('utc', value)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user