adjtimex(2) is a Linux specific libc function that gets and sets clock statuses, offsets, measurements, statuses, etc. These include the TAI leap second offset known to that host.
The function takes a struct timex *
which it both reads and populates.
This repositry contains Python wrappers of adjtimex(2), implemented with different FFI frameworks. So far there is
Framework | Language | Implementation |
---|---|---|
ctypes | ctypes_adjtimex.py | |
CFFI | cffi_adjtimex/ | |
Cython | cython_adjtimex/ | |
PyO3 | Rust | pyo3_adjtimex/ |
Each implementation contains a single module, exposing a single function
>>> import adjtimex
>>> adjtimex.tai_offset()
(0, 37)
0
is returned by adjtime(2)
, the clock is synchronised and no leap
seconds are pending.
37
is read from timex.tai
, the host knows that TAI is 37 seconds
ahead of UTC.
- Add Zig?
- CFFI built by Maturin?
- Port from setuptools -> pyproject.toml?
- Port to BSD? macOS? Windows?
- More in depth writeup
- CPython restricted API?
- PyPy3?
- WASM?
- https://github.com/moreati/scanwalk different implementations in branches