diff options
author | Maxime Buquet <pep@bouah.net> | 2022-07-12 13:38:52 +0200 |
---|---|---|
committer | Maxime Buquet <pep@bouah.net> | 2022-07-12 13:38:52 +0200 |
commit | 356f16f5afdcfc7470916c9ac61c2ad498a4389b (patch) | |
tree | a0df6fdf943ad94f04777b2fa8cbff9c13bf3177 | |
parent | b8f301b26fd1cc5f9b12263c79422e8be904b15b (diff) | |
parent | 65d70fe417d60eec1e2f68b02fc973bd236595ae (diff) | |
download | slixmpp-356f16f5afdcfc7470916c9ac61c2ad498a4389b.tar.gz slixmpp-356f16f5afdcfc7470916c9ac61c2ad498a4389b.tar.bz2 slixmpp-356f16f5afdcfc7470916c9ac61c2ad498a4389b.tar.xz slixmpp-356f16f5afdcfc7470916c9ac61c2ad498a4389b.zip |
Merge branch 'prevent-naive-datetime' into 'master'
XEP-0203: Prevent naïve datetime from being passed
Closes #3471
See merge request poezio/slixmpp!211
-rw-r--r-- | slixmpp/plugins/xep_0203/stanza.py | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/slixmpp/plugins/xep_0203/stanza.py b/slixmpp/plugins/xep_0203/stanza.py index f173d41c..a84cb52f 100644 --- a/slixmpp/plugins/xep_0203/stanza.py +++ b/slixmpp/plugins/xep_0203/stanza.py @@ -30,6 +30,10 @@ class Delay(ElementBase): def set_stamp(self, value): if isinstance(value, dt.datetime): + if value.tzinfo is None: + raise ValueError(f'Datetime provided without timezone information: {value}') + if value.tzinfo != dt.timezone.utc: + value = value.astimezone(dt.timezone.utc) value = xep_0082.format_datetime(value) self._set_attr('stamp', value) |