From ccf2b5655a816631a045e05d960d6f95fae12deb Mon Sep 17 00:00:00 2001 From: Stephen Chung Date: Sun, 31 Jul 2022 13:23:15 +0800 Subject: [PATCH] Add docs on timestamp. --- .../definitions/.rhai/definitions/__static__.d.rhai | 10 ++++++++++ src/packages/time_basic.rs | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/examples/definitions/.rhai/definitions/__static__.d.rhai b/examples/definitions/.rhai/definitions/__static__.d.rhai index ab0d2888..108ab58e 100644 --- a/examples/definitions/.rhai/definitions/__static__.d.rhai +++ b/examples/definitions/.rhai/definitions/__static__.d.rhai @@ -5208,6 +5208,16 @@ fn tan(x: float) -> float; fn tanh(x: float) -> float; /// 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; /// Convert the BLOB into an array of integers. diff --git a/src/packages/time_basic.rs b/src/packages/time_basic.rs index 4f51f8fe..b8bfa175 100644 --- a/src/packages/time_basic.rs +++ b/src/packages/time_basic.rs @@ -26,6 +26,16 @@ def_package! { #[export_module] mod time_functions { /// 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 { Instant::now() }