shithub: mc

ref: 779a3ef073261c6919ec2a65545435a35a3f5b6f
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

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