Merge branch 'prevent-naive-datetime' into 'master'
XEP-0203: Prevent naïve datetime from being passed Closes #3471 See merge request poezio/slixmpp!211
This commit is contained in:
commit
356f16f5af
1 changed files with 4 additions and 0 deletions
|
@ -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)
|
||||
|
||||
|
|
Loading…
Reference in a new issue