plugin XEP-0420: Implementation of Stanza Content Encryption:

Includes implementation of XEP-0082 (XMPP date and time profiles) and tests for both new plugins.
Everything is type checked, linted, format checked and unit tested.
Adds new dependency xmlschema.

fix 377
This commit is contained in:
Syndace 2022-08-23 12:04:11 +02:00
commit d1b5ff0c41

View file

@ -34,6 +34,7 @@ from twisted.python import procutils, failure
from twisted.internet import defer
from sat.core.constants import Const as C
from sat.core.log import getLogger
from sat.tools.datetime import format_date, format_datetime
log = getLogger(__name__)
@ -146,18 +147,16 @@ def xmpp_date(
to avoid reveling the timezone, we always return UTC dates
the string returned by this method is valid with RFC 3339
this function redirects to the functions in the :mod:`sat.tools.datetime` module
@param timestamp(None, float): posix timestamp. If None current time will be used
@param with_time(bool): if True include the time
@return(unicode): XEP-0082 formatted date and time
"""
template_date = "%Y-%m-%d"
template_time = "%H:%M:%SZ"
template = (
"{}T{}".format(template_date, template_time) if with_time else template_date
)
return datetime.datetime.utcfromtimestamp(
dtime = datetime.datetime.utcfromtimestamp(
time.time() if timestamp is None else timestamp
).strftime(template)
)
return format_datetime(dtime) if with_time else format_date(dtime.date())
def generatePassword(vocabulary=None, size=20):