Update subscription event expiry value to use time objects.
This commit is contained in:
parent
eafd2aee93
commit
eb25998e72
@ -6,9 +6,12 @@
|
|||||||
See the file LICENSE for copying permission.
|
See the file LICENSE for copying permission.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import datetime as dt
|
||||||
|
|
||||||
from sleekxmpp import Message
|
from sleekxmpp import Message
|
||||||
from sleekxmpp.xmlstream import register_stanza_plugin, ElementBase, ET, JID
|
from sleekxmpp.xmlstream import register_stanza_plugin, ElementBase, ET, JID
|
||||||
from sleekxmpp.plugins.xep_0004 import Form
|
from sleekxmpp.plugins.xep_0004 import Form
|
||||||
|
from sleekxmpp.plugins import xep_0082
|
||||||
|
|
||||||
|
|
||||||
class Event(ElementBase):
|
class Event(ElementBase):
|
||||||
@ -116,6 +119,15 @@ class EventSubscription(ElementBase):
|
|||||||
plugin_attrib = name
|
plugin_attrib = name
|
||||||
interfaces = set(('node', 'expiry', 'jid', 'subid', 'subscription'))
|
interfaces = set(('node', 'expiry', 'jid', 'subid', 'subscription'))
|
||||||
|
|
||||||
|
def get_expiry(self):
|
||||||
|
expiry = self._get_attr('expiry')
|
||||||
|
return xep_0082.parse(expiry)
|
||||||
|
|
||||||
|
def set_expiry(self, value):
|
||||||
|
if isinstance(value, dt.datetime):
|
||||||
|
value = xep_0082.format_datetime(value)
|
||||||
|
self._set_attr('expiry', value)
|
||||||
|
|
||||||
def set_jid(self, value):
|
def set_jid(self, value):
|
||||||
self._set_attr('jid', str(value))
|
self._set_attr('jid', str(value))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user