Skip to main content
`Ctrl`+`K`
⚠️The latest release refactored our HTML, so double-check your custom CSS rules!⚠️

# API documentation

Using Sphinx’s `sphinx.ext.autodoc` plugin, it is possible to auto-generate documentation of a Python module.

Tip

Avoid having in-function-signature type annotations with autodoc, by setting the following options:

    # -- Options for autodoc ----------------------------------------------------
    # https://www.sphinx-doc.org/en/master/usage/extensions/autodoc.html#configuration

    # Automatically extract typehints when specified and place them in
    # descriptions of the relevant function/method.
    autodoc_typehints = "description"

    # Don't show class signature with the class' name.
    autodoc_class_signature = "separated"

Specific date/time and related types.

See https://data.iana.org/time-zones/tz-link.html for time zone and DST data sources.

class datetime.date

  date(year, month, day) –> date object

  ctime(/)

    Return ctime() style string.

  classmethod fromisocalendar()

    int, int, int -> Construct a date from the ISO year, week number and weekday.

    This is the inverse of the date.isocalendar() function

  classmethod fromisoformat(object, /)

    str -> Construct a date from a string in ISO 8601 format.

  classmethod fromordinal()

    int -> date corresponding to a proleptic Gregorian ordinal.

  classmethod fromtimestamp(timestamp, /)

    Create a date from a POSIX timestamp.

    The timestamp is a number, e.g. created via time.time(), that is interpreted as local time.

  isocalendar(/)

    Return a named tuple containing ISO year, week number, and weekday.

  isoformat(/)

    Return string in ISO 8601 format, YYYY-MM-DD.

  isoweekday(/)

    Return the day of the week represented by the date. Monday == 1 … Sunday == 7

  strftime()

    format -> strftime() style string.

  classmethod strptime()

    string, format -> new date parsed from a string (like time.strptime()).

  timetuple(/)

    Return time tuple, compatible with time.localtime().

  classmethod today(/)

    Current date or datetime: same as self.__class__.fromtimestamp(time.time()).

  toordinal(/)

    Return proleptic Gregorian ordinal. January 1 of year 1 is day 1.

  weekday(/)

    Return the day of the week represented by the date. Monday == 0 … Sunday == 6

class datetime.datetime(year, month, day[, hour[, minute[, second[, microsecond[, tzinfo]]]]])

  The year, month and day arguments are required. tzinfo may be None, or an instance of a tzinfo subclass. The remaining arguments may be ints.

  astimezone()

    tz -> convert to local time in new timezone tz

  classmethod combine()

    date, time -> datetime with same date and time fields

  ctime(/)

    Return ctime() style string.

  date(/)

    Return date object with same year, month and day.

  dst(/)

    Return self.tzinfo.dst(self).

  classmethod fromisoformat(object, /)

    string -> datetime from a string in most ISO 8601 formats

  classmethod fromtimestamp()

    timestamp[, tz] -> tz’s local time from POSIX timestamp.

  isoformat()

    [sep] -> string in ISO 8601 format, YYYY-MM-DDT[HH[:MM[:SS[.mmm[uuu]]]]][+HH:MM]. sep is used to separate the year from the time, and defaults to ‘T’. The optional argument timespec specifies the number of additional terms of the time to include. Valid options are ‘auto’, ‘hours’, ‘minutes’, ‘seconds’, ‘milliseconds’ and ‘microseconds’.

  classmethod now(/, tz=None)

    Returns new datetime object representing current time local to tz.

    > tz

    >   Timezone object.

    If no tz is specified, uses local timezone.

  classmethod strptime()

    string, format -> new datetime parsed from a string (like time.strptime()).

  time(/)

    Return time object with same time but with tzinfo=None.

  timestamp(/)

    Return POSIX timestamp as float.

  timetuple(/)

    Return time tuple, compatible with time.localtime().

  timetz(/)

    Return time object with same time and tzinfo.

  tzname(/)

    Return self.tzinfo.tzname(self).

  classmethod utcfromtimestamp()

    Construct a naive UTC datetime from a POSIX timestamp.

  classmethod utcnow(/)

    Return a new datetime representing UTC day and time.

  utcoffset(/)

    Return self.tzinfo.utcoffset(self).

  utctimetuple(/)

    Return UTC time tuple, compatible with time.localtime().

class datetime.time

  time([hour[, minute[, second[, microsecond[, tzinfo]]]]]) –> a time object

  All arguments are optional. tzinfo may be None, or an instance of a tzinfo subclass. The remaining arguments may be ints.

  dst(/)

    Return self.tzinfo.dst(self).

  classmethod fromisoformat(object, /)

    string -> time from a string in ISO 8601 format

  isoformat()

    Return string in ISO 8601 format, [HH[:MM[:SS[.mmm[uuu]]]]][+HH:MM].

    The optional argument timespec specifies the number of additional terms of the time to include. Valid options are ‘auto’, ‘hours’, ‘minutes’, ‘seconds’, ‘milliseconds’ and ‘microseconds’.

  strftime()

    format -> strftime() style string.

  classmethod strptime()

    string, format -> new time parsed from a string (like time.strptime()).

  tzname(/)

    Return self.tzinfo.tzname(self).

  utcoffset(/)

    Return self.tzinfo.utcoffset(self).

class datetime.timedelta

  Difference between two datetime values.

  timedelta(days=0, seconds=0, microseconds=0, milliseconds=0, minutes=0, hours=0, weeks=0)

  All arguments are optional and default to 0. Arguments may be integers or floats, and may be positive or negative.

  days

    Number of days.

  microseconds

    Number of microseconds (>= 0 and less than 1 second).

  seconds

    Number of seconds (>= 0 and less than 1 day).

  total_seconds(/)

    Total seconds in the duration.

class datetime.timezone

  Fixed offset from UTC implementation of tzinfo.

  dst(object, /)

    Return None.

  fromutc(object, /)

    datetime in UTC -> datetime in local time.

  tzname(object, /)

    If name is specified when timezone is created, returns the name. Otherwise returns offset as ‘UTC(+|-)HH:MM’.

  utcoffset(object, /)

    Return fixed offset.

class datetime.tzinfo

  Abstract base class for time zone info objects.

  dst(object, /)

    datetime -> DST offset as timedelta positive east of UTC.

  fromutc(object, /)

    datetime in UTC -> datetime in local time.

  tzname(object, /)

    datetime -> string name of time zone.

  utcoffset(object, /)

    datetime -> timedelta showing offset from UTC, negative values indicating West of UTC