Cyclium.Window (Cyclium v0.1.9)

Copy Markdown View Source

Clock-aligned dedupe bucket helpers.

All functions are pure — no state, no side effects. Use bucket/2 to generate a deterministic, time-bounded string key for deduplication.

Bucket Sizes

  • :h4 — 4-hour windows aligned to 00, 04, 08, 12, 16, 20 UTC
  • :h24 — daily (midnight UTC boundary)
  • :h48 — every-other-day by ordinal day of year
  • :w1 — ISO week (Monday 00:00 UTC boundary)

Examples

iex> Cyclium.Window.bucket(:h4, ~U[2026-02-23 13:45:00Z])
"2026-02-23T12"

iex> Cyclium.Window.bucket(:h24, ~U[2026-02-23 13:45:00Z])
"2026-02-23"

Summary

Types

window_size()

@type window_size() :: :h4 | :h24 | :h48 | :w1

Functions

bucket(atom, dt)

@spec bucket(window_size(), DateTime.t()) :: String.t()