XmlPeriod

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

Concrete xs:gYear/Month/Day builtin type.

Represents iso 8601 period formats with rich comparisons and hashing.

Formats:
  • xs:gDay: —%d%z

  • xs:gMonth: –%m%z

  • xs:gYear: %Y%z

  • xs:gMonthDay: –%m-%d%z

  • xs:gYearMonth: %Y-%m%z

Parameters

value (str) – String representation of a xs:period, eg –11-01Z

property year: Optional[int]

Period year.

Return type

Optional[int]

property month: Optional[int]

Period month.

Return type

Optional[int]

property day: Optional[int]

Period day.

Return type

Optional[int]

property offset: Optional[int]

Period timezone offset in minutes.

Return type

Optional[int]

as_dict()[source]

Return date units as dict.

Return type

Dict

__eq__(other)[source]

Return self==value.

Return type

bool

__ge__(string)

Return self>=value.

__gt__(string)

Return self>value.

__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.