docs: baked a lot of API docs

This commit is contained in:
Zef Hemel
2026-08-06 14:48:21 +02:00
parent 9b4de31ca3
commit 754e8525b9
36 changed files with 4888 additions and 49 deletions
+70 -1
View File
@@ -27,4 +27,73 @@ The `os` namespace provides date, time, and clock functions.
- `%Z` and `%z`: time zone name and UTC offset
- `%%`: literal percent sign
${spacelua.renderApiDocumentation("os")}
<!--#lua spacelua.renderApiDocumentation("os") -->
## os.clock
`os.clock()`
Returns a high-resolution elapsed time value in seconds.
**Returns:**
- `number` — Browser performance timer in seconds.
## os.date
`os.date(format?, timestamp?)`
Formats a timestamp as a date string or date table, optionally in UTC.
**Parameters:**
- `format?` (`string`) — `strftime`-style format, `*t` for a table, and optional leading `!` for UTC.
- `timestamp?` (`number`) — Unix timestamp; defaults to the current time.
**Returns:**
- `string|table` — Formatted date or date fields.
**Example:**
```lua
print(os.date("%Y-%m-%d"))
local utc = os.date("!*t")
```
## os.difftime
`os.difftime(t2, t1)`
Returns the difference in seconds from timestamp `t1` to `t2`.
**Parameters:**
- `t2` (`number`)
- `t1` (`number`)
**Returns:**
- `number` — The value `t2 - t1` in seconds.
## os.time
`os.time(): integer`
`os.time(dateTable): integer`
Returns the current Unix timestamp or one built from a local date table.
**Parameters:**
- `dateTable?` (`table`) — Local date fields `year`, `month`, `day`, and optional `hour`, `min`, and `sec`.
**Returns:**
- `integer` — Seconds since the Unix epoch.
**Example:**
```lua
local timestamp = os.time({year = 2020, month = 1, day = 1})
```
<!--/lua-->