aboutsummaryrefslogtreecommitdiff
path: root/docs/library
diff options
context:
space:
mode:
authorDamien George2020-09-24 12:37:02 +1000
committerDamien George2020-10-01 14:20:42 +1000
commitd4b61b00172ccc231307e3ef33f66f28cb6b051f (patch)
tree193b39ce0aa2a542d6f3ea6c96aadbe8f523858b /docs/library
parent905a18aafefbe04aa2beceb84885c29aa156b975 (diff)
extmod/utime_mphal: Add generic utime.time_ns() function.
It requires mp_hal_time_ns() to be provided by a port. This function allows very accurate absolute timestamps. Enabled on unix, windows, stm32, esp8266 and esp32. Signed-off-by: Damien George <damien@micropython.org>
Diffstat (limited to 'docs/library')
-rw-r--r--docs/library/utime.rst10
1 files changed, 8 insertions, 2 deletions
diff --git a/docs/library/utime.rst b/docs/library/utime.rst
index 8c222ede5..86fd27b3a 100644
--- a/docs/library/utime.rst
+++ b/docs/library/utime.rst
@@ -216,8 +216,9 @@ Functions
function returns number of seconds since a port-specific reference point in time (for
embedded boards without a battery-backed RTC, usually since power up or reset). If you
want to develop portable MicroPython application, you should not rely on this function
- to provide higher than second precision. If you need higher precision, use
- `ticks_ms()` and `ticks_us()` functions, if you need calendar time,
+ to provide higher than second precision. If you need higher precision, absolute
+ timestamps, use `time_ns()`. If relative times are acceptable then use the
+ `ticks_ms()` and `ticks_us()` functions. If you need calendar time, `gmtime()` or
`localtime()` without an argument is a better choice.
.. admonition:: Difference to CPython
@@ -233,3 +234,8 @@ Functions
hardware also lacks battery-powered RTC, so returns number of seconds
since last power-up or from other relative, hardware-specific point
(e.g. reset).
+
+.. function:: time_ns()
+
+ Similar to `time()` but returns nanoseconds since the Epoch, as an integer (usually
+ a big integer, so will allocate on the heap).