td36/README.md

16 lines
626 B
Markdown
Raw Permalink Normal View History

2026-09-13 00:11:23 +03:00
# td36
Time-delta identifiers: a timestamp is stored as the base36 encoding of its offset from a chosen epoch, so ids stay short, sortable and monotonically increasing.
```rust
use td36::{Td36Epoch, Td36Precision};
let epoch = Td36Epoch::new(1_700_000_000, Td36Precision::Seconds);
let id = epoch.encode(1_700_000_123).unwrap();
assert_eq!(epoch.decode_id(&id).unwrap(), 1_700_000_123);
```
`Td36Epoch::encode_epoch_marker` / `decode_epoch_marker` round-trip the epoch itself, so a stream of ids can carry the epoch it is relative to.
No dependencies. `cargo test` covers epoch round-tripping and the before-epoch guard.