From 7921d552aeedac88e65fca320221e6c5baabb2e5 Mon Sep 17 00:00:00 2001 From: Sebastien Binet Date: Mon, 10 Jan 2022 16:39:57 +0100 Subject: [PATCH] time: add time_ns function --- time/time.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/time/time.go b/time/time.go index 88deb94a..c028966a 100644 --- a/time/time.go +++ b/time/time.go @@ -21,6 +21,15 @@ func time_time(self py.Object) (py.Object, error) { return py.Float(time.Now().UnixNano()) / 1e9, nil } +const time_ns_doc = `time_ns() -> int + +Return the current time in nanoseconds since the Epoch. +` + +func time_time_ns(self py.Object) (py.Object, error) { + return py.Int(time.Now().UnixNano()), nil +} + // func floatclock(_Py_clock_info_t *info) (py.Object, error) { // value := clock() // if value == (clock_t)-1 { @@ -979,6 +988,7 @@ func PyInit_timezone(m py.Object) { func init() { methods := []*py.Method{ py.MustNewMethod("time", time_time, 0, time_doc), + py.MustNewMethod("time_ns", time_time_ns, 0, time_ns_doc), py.MustNewMethod("clock", time_clock, 0, clock_doc), py.MustNewMethod("clock_gettime", time_clock_gettime, 0, clock_gettime_doc), py.MustNewMethod("clock_settime", time_clock_settime, 0, clock_settime_doc), @@ -1037,6 +1047,7 @@ tzname -- tuple of (standard time zone name, DST time zone name) Functions: time() -- return current time in seconds since the Epoch as a float +time_ns() -- return current time in nanoseconds since the Epoch clock() -- return CPU time since process start as a float sleep() -- delay for a number of seconds given as a float gmtime() -- convert seconds since Epoch to UTC tuple pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy