Pure calendar arithmetic on epoch seconds — the date-arithmetic stone (R4a's last engine-side gap). Time columns stay declared i64 (epoch seconds; units belong to the caller, the WINDOW philosophy) — this crate is the query-side arithmetic that turns a human bound into that i64, never a new column type.
Everything here is a pure function: now is always an argument,
the stone never touches a clock. Proleptic Gregorian, UTC only
(zone conversion is the application's — refused by name at the
surface, not silently guessed here).
The civil conversion is the standard integer-arithmetic algorithm (era/year-of-era/day-of-year decomposition over 400-year cycles), exact over the whole i64 day range the epoch can reach.
use ;
// Epoch seconds in, calendar out, and back again.
let c = civil_from_epoch;
assert_eq!;
assert_eq!;
assert_eq!;
// Month arithmetic clamps rather than spilling into the next month:
// 31 January plus one month is the last day of February, and 2024 is
// a leap year.
let jan31 = epoch_from_civil;
let feb = civil_from_epoch;
assert_eq!;