shithub: mc

ref: 5fc8fe7bec594a98c7a2b9fbdfc5f7fb4f11c7c9
dir: /libstd/now.myr/

View raw version
use "sys.use"
use "types.use"
use "fmt.use"

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

/* milliseconds since epoch */
const now = {
	var tm
	var sec
	var nsec
	
	sec = tm.sec
	nsec = tm.nsec castto(uint64)
	if clock_gettime(`Clockrealtime, &tm) == 0
		-> (sec*1000 + nsec/(1000*1000)) castto(time)
	else
		-> -1
	;;
}