:mod:`time` =========== .. py:module:: time .. autoapi-nested-parse:: time and timing related functions The `time` module is a strict subset of the CPython `cpython:time` module. So, code written in MicroPython will work in CPython but not necessarily the other way around. .. function:: monotonic() -> Any Returns an always increasing value of time with an unknown reference point. Only use it to compare against other values from `monotonic`. :return: the current monotonic time :rtype: float .. function:: sleep(seconds: float) -> Any Sleep for a given number of seconds. :param float seconds: the time to sleep in fractional seconds .. py:class:: struct_time(time_tuple: Any) .. function:: time() -> Any Return the current time in seconds since since Jan 1, 1970. :return: the current time :rtype: int .. function:: monotonic_ns() -> Any Return the time of the specified clock clk_id in nanoseconds. :return: the current time :rtype: int .. function:: localtime(secs: Any) -> Any Convert a time expressed in seconds since Jan 1, 1970 to a struct_time in local time. If secs is not provided or None, the current time as returned by time() is used. The earliest date for which it can generate a time is Jan 1, 2000. :return: the current time :rtype: time.struct_time .. function:: mktime(t: Any) -> Any This is the inverse function of localtime(). Its argument is the struct_time or full 9-tuple (since the dst flag is needed; use -1 as the dst flag if it is unknown) which expresses the time in local time, not UTC. The earliest date for which it can generate a time is Jan 1, 2000. :return: seconds :rtype: int