Add docs on timestamp.

This commit is contained in:
Stephen Chung 2022-07-31 13:23:15 +08:00
parent d5f9b0f5c6
commit ccf2b5655a
2 changed files with 20 additions and 0 deletions

View File

@ -5208,6 +5208,16 @@ fn tan(x: float) -> float;
fn tanh(x: float) -> float; fn tanh(x: float) -> float;
/// Create a timestamp containing the current system time. /// Create a timestamp containing the current system time.
///
/// # Example
///
/// ```rhai
/// let now = timestamp();
///
/// sleep(10.0); // sleep for 10 seconds
///
/// print(now.elapsed); // prints 10.???
/// ```
fn timestamp() -> Instant; fn timestamp() -> Instant;
/// Convert the BLOB into an array of integers. /// Convert the BLOB into an array of integers.

View File

@ -26,6 +26,16 @@ def_package! {
#[export_module] #[export_module]
mod time_functions { mod time_functions {
/// Create a timestamp containing the current system time. /// Create a timestamp containing the current system time.
///
/// # Example
///
/// ```rhai
/// let now = timestamp();
///
/// sleep(10.0); // sleep for 10 seconds
///
/// print(now.elapsed); // prints 10.???
/// ```
pub fn timestamp() -> Instant { pub fn timestamp() -> Instant {
Instant::now() Instant::now()
} }