def set_timestamp(self, value: Union[datetime, str]): """Set the timestamp. :param value: Value of the timestamp (either a datetime or a XEP-0082 timestamp string. """ if isinstance(value, str): value = xep_0082.parse(value) value = xep_0082.format_datetime(value) self.xml.attrib['timestamp'] = value
def set_end(self, value): if isinstance(value, dt.datetime): value = xep_0082.format_datetime(value) fields = self.__get_fields() field = fields.get('end') if field: field['value'] = value else: field = self._form.add_field(var='end') field['value'] = value
def set_utc(self, value): """ Set the time in UTC. :param value: A datetime object or properly formatted string equivalent. """ date = value if not isinstance(value, dt.datetime): date = xep_0082.parse(value) date = date.astimezone(tzutc()) value = xep_0082.format_datetime(date) self._set_sub_text('utc', value)
def set_utc(self, value): """ Set the time in UTC. Arguments: value -- A datetime object or properly formatted string equivalent. """ date = value if not isinstance(value, dt.datetime): date = xep_0082.parse(value) date = date.astimezone(tzutc()) value = xep_0082.format_datetime(date)[:-1] self._set_sub_text('utc', value)
def set_rev(self, value): if isinstance(value, dt.datetime): value = xep_0082.format_datetime(value) self.xml.text = value
def set_end(self, value): if isinstance(value, dt.datetime): value = xep_0082.format_datetime(value) self._set_sub_text('end', value)
def set_stamp(self, value): if isinstance(value, dt.datetime): value = xep_0082.format_datetime(value) self._set_attr('stamp', value)
def set_stamp(self, value): if isinstance(value, dt.datetime): value = value.astimezone(xep_0082.tzutc) value = xep_0082.format_datetime(value) self._set_attr('stamp', value[0:19].replace('-', ''))
def set_expiry(self, value): if isinstance(value, dt.datetime): value = xep_0082.format_datetime(value) self._set_attr('expiry', value)
def set_start(self, value: Union[str, datetime]): self._setup_form() if isinstance(value, datetime): value = xep_0082.format_datetime(value) self.set_custom_field('start', value)
def set_end(self, value: Union[str, datetime]): if isinstance(value, datetime): value = xep_0082.format_datetime(value) self.set_custom_field('end', value)
def set_date(self, value): if isinstance(value, dt.datetime): value = xep_0082.format_datetime(value) self._set_attr("date", value)