shithub: mc

ref: 14c0d8b03e8390c4f06bde071294a0c2325e8c7f
dir: /libstd/now.myr/

View raw version
use sys

use "types.use"
use "fmt.use"

pkg std =
	const now	: (-> time)
;;

/* microseconds since epoch */
const now = {
	var tm
	var sec
	var nsec

	if sys.clock_gettime(`sys.Clockrealtime, &tm) == 0
		sec = tm.sec
		nsec = tm.nsec castto(uint64)
		-> (sec*1_000_000 + nsec/1000) castto(time)
	else
		-> -1
	;;
}