# XmlDate

class xsdata.models.datatype.XmlDate(year: int, month: int, day: int, offset: Optional[int] = None)

  Concrete xs:date builtin type.

  Represents iso 8601 date format [-]CCYY-MM-DD[Z|(+|-)hh:mm] with rich comparisons and hashing.

  Parameters

    - year – Any signed integer, eg (0, -535, 2020)

    - month – Unsigned integer between 1-12

    - day – Unsigned integer between 1-31

    - offset – Signed integer representing timezone offset in minutes

  year: int

    Alias for field number 0

  month: int

    Alias for field number 1

  day: int

    Alias for field number 2

  offset: Optional[int]

    Alias for field number 3

  replace(year=None, month=None, day=None, offset=True)

    Return a new instance replacing the specified fields with new values.

    Return type

      `XmlDate`

  classmethod from_string(string)

    Initialize from string with format `%Y-%m-%dT%z`

    Return type

      `XmlDate`

  classmethod from_date(obj)

    Initialize from `datetime.date` instance.

    Warning

    date instances don’t have timezone information!

    Return type

      `XmlDate`

  classmethod from_datetime(obj)

    Initialize from `datetime.datetime` instance.

    Return type

      `XmlDate`

  classmethod today()

    Initialize from datetime.date.today()

    Return type

      `XmlDate`

  to_date()

    Return a `datetime.date` instance.

    Return type

      `date`

  to_datetime()

    Return a `datetime.datetime` instance.

    Return type

      `datetime`

  __str__()

    Return the date formatted according to ISO 8601 for xml.

    Examples:

      - 2001-10-26

      - 2001-10-26+02:00

      - 2001-10-26Z

    Return type

      `str`

  __add__(value, /)

    Return self+value.

  __class_getitem__()

    See PEP 585

  __contains__(key, /)

    Return key in self.

  __eq__(value, /)

    Return self==value.

  __ge__(value, /)

    Return self>=value.

  __getattribute__(name, /)

    Return getattr(self, name).

  __getitem__(key, /)

    Return self[key].

  __getnewargs__()

    Return self as a plain tuple. Used by copy and pickle.

  __gt__(value, /)

    Return self>value.

  __hash__()

    Return hash(self).

  __iter__()

    Implement iter(self).

  __le__(value, /)

    Return self<=value.

  __len__()

    Return len(self).

  __lt__(value, /)

    Return self<value.

  __mul__(value, /)

    Return self*value.

  __ne__(value, /)

    Return self!=value.

  __rmul__(value, /)

    Return value*self.

  count(value, /)

    Return number of occurrences of value.

  index(value, start=0, stop=9223372036854775807, /)

    Return first index of value.

    Raises ValueError if the value is not present.