XmlDuration

class xsdata.models.datatype.XmlDuration(value)[source]

Concrete xs:duration builtin type.

Represents iso 8601 duration format PnYnMnDTnHnMnS with rich comparisons and hashing.

Format PnYnMnDTnHnMnS:
  • P: literal value that starts the expression

  • nY: the number of years followed by a literal Y

  • nM: the number of months followed by a literal M

  • nD: the number of days followed by a literal D

  • T: literal value that separates date and time parts

  • nH: the number of hours followed by a literal H

  • nM: the number of minutes followed by a literal M

  • nS: the number of seconds followed by a literal S

Parameters

value (str) – String representation of a xs:duration, eg P2Y6M5DT12H

property years: Optional[int]

Number of years in the interval.

Return type

Optional[int]

property months: Optional[int]

Number of months in the interval.

Return type

Optional[int]

property days: Optional[int]

Number of days in the interval.

Return type

Optional[int]

property hours: Optional[int]

Number of hours in the interval.

Return type

Optional[int]

property minutes: Optional[int]

Number of minutes in the interval.

Return type

Optional[int]

property seconds: Optional[float]

Number of seconds in the interval.

Return type

Optional[float]

property negative: bool

Negative flag of the interval.

Return type

bool

__eq__(string)

Return self==value.

__ge__(string)

Return self>=value.

__gt__(string)

Return self>value.

__hash__()

Return hash(self).

__le__(string)

Return self<=value.

__lt__(string)

Return self<value.

__str__()

Return str(self).

classmethod __subclasshook__(C)

Abstract classes can override this to customize issubclass().

This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).

count(value) integer return number of occurrences of value
index(value[, start[, stop]]) integer return first index of value.

Raises ValueError if the value is not present.

Supporting start and stop arguments is optional, but recommended.

maketrans()

Return a translation table usable for str.translate().

If there is only one argument, it must be a dictionary mapping Unicode ordinals (integers) or characters to Unicode ordinals, strings or None. Character keys will be then converted to ordinals. If there are two arguments, they must be strings of equal length, and in the resulting dictionary, each character in x will be mapped to the character at the same position in y. If there is a third argument, it must be a string, whose characters will be mapped to None in the result.