summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--slixmpp/plugins/xep_0319/idle.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/slixmpp/plugins/xep_0319/idle.py b/slixmpp/plugins/xep_0319/idle.py
index 65500706..9d77ed96 100644
--- a/slixmpp/plugins/xep_0319/idle.py
+++ b/slixmpp/plugins/xep_0319/idle.py
@@ -6,7 +6,7 @@
See the file LICENSE for copying permission.
"""
-from datetime import datetime, timedelta
+from datetime import datetime, timedelta, timezone
from slixmpp.stanza import Presence
from slixmpp.plugins import BasePlugin
@@ -16,6 +16,10 @@ from slixmpp.xmlstream.matcher import StanzaPath
from slixmpp.plugins.xep_0319 import stanza
+def get_local_timezone():
+ return datetime.now(timezone.utc).astimezone().tzinfo
+
+
class XEP_0319(BasePlugin):
name = 'xep_0319'
description = 'XEP-0319: Last User Interaction in Presence'
@@ -47,10 +51,11 @@ class XEP_0319(BasePlugin):
def idle(self, jid=None, since=None):
seconds = None
+ timezone = get_local_timezone()
if since is None:
- since = datetime.now()
+ since = datetime.now(timezone)
else:
- seconds = datetime.now() - since
+ seconds = datetime.now(timezone) - since
self.api['set_idle'](jid, None, None, since)
self.xmpp['xep_0012'].set_last_activity(jid=jid, seconds=seconds)