shithub: mc

ref: 5e6ffbb015dc6f204b5da226dabac8b15d666216
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

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