rust/src/libstd/time.rs

31 lines
619 B
Rust
Raw Normal View History

2011-10-27 16:54:18 -05:00
/*
Module: time
*/
2011-10-27 16:54:18 -05:00
// FIXME: Document what these functions do
#[abi = "cdecl"]
native mod rustrt {
2011-09-12 05:39:38 -05:00
fn get_time(&sec: u32, &usec: u32);
fn nano_time(&ns: u64);
}
2011-10-27 16:54:18 -05:00
/* Type: timeval */
2011-07-27 07:19:39 -05:00
type timeval = {sec: u32, usec: u32};
2011-10-27 16:54:18 -05:00
/* Function: get_time */
fn get_time() -> timeval {
2011-07-27 07:19:39 -05:00
let sec = 0u32;
let usec = 0u32;
2011-06-10 09:39:09 -05:00
rustrt::get_time(sec, usec);
2011-07-27 07:19:39 -05:00
ret {sec: sec, usec: usec};
}
2011-10-27 16:54:18 -05:00
/* Function: precise_time_ns */
2011-07-27 07:19:39 -05:00
fn precise_time_ns() -> u64 { let ns = 0u64; rustrt::nano_time(ns); ret ns; }
2011-10-27 16:54:18 -05:00
/* Function: precise_time_s */
fn precise_time_s() -> float {
ret (precise_time_ns() as float) / 1000000000.;
}