aboutsummaryrefslogtreecommitdiff
path: root/core/time/time_js.odin
blob: 932fc2b8e9f56143291a139a019287fafe4b9641 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
//+private
//+build js
package time

foreign import "odin_env"

_IS_SUPPORTED :: true

_now :: proc "contextless" () -> Time {
	foreign odin_env {
		time_now :: proc "contextless" () -> i64 ---
	}
	return Time{time_now()*1e6}
}

_sleep :: proc "contextless" (d: Duration) {
	foreign odin_env {
		time_sleep :: proc "contextless" (ms: u32) ---
	}
	if d > 0 {
		time_sleep(u32(d/1e6))
	}
}

_tick_now :: proc "contextless" () -> Tick {
	foreign odin_env {
		tick_now :: proc "contextless" () -> i64 ---
	}
	return Tick{tick_now()*1e6}
}

_yield :: proc "contextless" () {
}