Skip to content

Commit ac7efd2

Browse files
docs(time): Document time host package.
1 parent 9266783 commit ac7efd2

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

documentation/reference/packages.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,20 @@ idb_put(db, "items", "1", '{"title":"hello"}')
108108

109109
Handlers: `local_get/set/remove/clear/keys`, `session_*` (same surface), `idb_open`, `idb_put`, `idb_get`, `idb_delete`, `idb_keys`, `idb_close`. Full API: [`storage/README.md`](https://github.com/dylan-sutton-chavez/edge-python-host/tree/main/storage).
110110

111+
### `time`
112+
113+
Wall and monotonic clocks, sleep, and calendar formatting, a sandbox-friendly subset of CPython's `time`. Clock reads are synchronous; `sleep` suspends the coroutine like `network`'s `fetch`, composing with `gather` / `with_timeout`. A `struct_time` crosses as a JSON nine-tuple string, decode it with `json` to read fields.
114+
115+
```python
116+
from time import time, sleep, strftime, gmtime
117+
118+
print(time()) # seconds since the epoch
119+
sleep(0.1) # suspends, resumes after ~100ms
120+
print(strftime("%Y-%m-%d", gmtime(0))) # 1970-01-01
121+
```
122+
123+
Handlers: `time`, `time_ns`, `monotonic`, `monotonic_ns`, `perf_counter`, `perf_counter_ns`, `sleep`, `gmtime`, `localtime`, `mktime`, `strftime`, `strptime`, `asctime`, `ctime`, `timezone`, `altzone`, `daylight`, `tzname`. CPU, thread, and POSIX clocks (`process_time`, `clock_gettime`, `tzset`, the `CLOCK_*` constants) are intentionally out of scope. Full API: [`time/README.md`](https://github.com/dylan-sutton-chavez/edge-python-host/tree/main/time).
124+
111125
## How to load them
112126

113127
| You have... | Do |

0 commit comments

Comments
 (0)