File tree Expand file tree Collapse file tree 3 files changed +19
-0
lines changed
Expand file tree Collapse file tree 3 files changed +19
-0
lines changed Original file line number Diff line number Diff line change 99- The ` result ` module gains the ` all ` function.
1010- The ` dynamic ` module gains the ` option ` function.
1111- The ` uri ` module gains the ` percent_encode ` and ` percent_decode ` functions.
12+ - The ` os ` module gains the ` erlang_timestamp ` function.
1213
1314## v0.11.0 - 2020-08-22
1415
Original file line number Diff line number Diff line change @@ -58,3 +58,9 @@ pub type TimeUnit {
5858/// https://erlang.org/doc/apps/erts/time_correction.html#OS_System_Time
5959pub external fn system_time ( TimeUnit ) -> Int =
6060 "os" "system_time"
61+
62+ /// Return the current OS system time as a tuple of Ints
63+ ///
64+ /// http://erlang.org/doc/man/os.html#timestamp-0
65+ pub external fn erlang_timestamp ( ) -> tuple ( Int, Int, Int) =
66+ "os" "timestamp"
Original file line number Diff line number Diff line change @@ -26,3 +26,15 @@ pub fn system_time_test() {
2626 { os . system_time ( os . Millisecond ) < june_12_2020 * 1000000 }
2727 |> should . equal ( True )
2828}
29+
30+ pub fn erlang_timestamp_test ( ) {
31+ // in microseconds
32+ let june_12_2020 = 1591966971000000
33+ let tuple ( mega_seconds, seconds, micro_seconds) = os . erlang_timestamp ( )
34+
35+ let stamp_as_micro =
36+ { mega_seconds * 1_000_000 + seconds } * 1_000_000 + micro_seconds
37+
38+ { stamp_as_micro > june_12_2020 }
39+ |> should . be_true ( )
40+ }
You can’t perform that action at this time.
0 commit comments