Skip to content

Commit 01f8a94

Browse files
authored
docs(timeutil): revise timeutil documentation for clarity and examples
Updated documentation for the timeutil module to clarify its compatibility and usage examples.
1 parent f3c0450 commit 01f8a94

1 file changed

Lines changed: 26 additions & 15 deletions

File tree

docs/src/timeutil/index.md

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,34 @@
33
`timeutil` is a C-backed Lua module for wall-clock time, monotonic time, and
44
blocking sleep.
55

6-
It lets Lua read Unix wall-clock timestamps, measure elapsed monotonic time, and
7-
pause execution for a duration.
6+
Compatible with Lua 5.1, 5.2, 5.3, 5.4, 5.5, and LuaJIT.
87

9-
## Compatibility
8+
Use `timeutil` to read Unix wall-clock timestamps, measure elapsed monotonic
9+
time without wall-clock jumps, and sleep for fractional-second durations.
1010

11-
`timeutil` supports:
11+
## Install
1212

13-
- Lua 5.1
14-
- Lua 5.2
15-
- Lua 5.3
16-
- Lua 5.4
17-
- Lua 5.5
18-
- LuaJIT
13+
::: code-group
1914

20-
## Use Cases
15+
```sh [LuaRocks]
16+
luarocks install timeutil
17+
```
2118

22-
- Get Unix wall-clock time from Lua.
23-
- Measure elapsed time without wall-clock jumps.
24-
- Sleep for fractional-second durations.
25-
- Write timing, polling, timeout, and benchmark code.
19+
:::
20+
21+
## Quick Start
22+
23+
::: code-group
24+
25+
```lua [exmaple.lua]
26+
local time = require "timeutil"
27+
28+
local start = time.mono()
29+
time.sleep(0.05)
30+
local elapsed = time.mono() - start
31+
32+
print(("elapsed: %.3fs"):format(elapsed))
33+
print(("now: %.3f"):format(time.now()))
34+
```
35+
36+
:::

0 commit comments

Comments
 (0)