ed564b6dda
Phase 1.5 of time-system. Calendar is pluggable: EarthCalendar (IANA zones, DST, Gregorian) is the default; MarsCalendar, CycleCalendar(period), NoCycleCalendar handle non-Earth cases. Rhythm abstracts recurrence from clock units - rhythm_cycle_phase(0.5) means "midpoint of cycle" whether the cycle is 24 hours on Earth or 30 hours on a station or 300 years on a long-cycle world. Phase 1 (Instant + Duration) unchanged. EarthCalendar(zone_local()) is the user-facing default; nobody who doesn't care about non-Earth calendars sees the abstraction. Self-host fixed point holds at 6339 lines. Snapshot tagged at dist/platform/elc.20260502-1321-self-host. Phase 2 (scheduling primitives every/after/at) lands next, now with Calendar-aware grounding instead of Earth-time hardcoded. Backlog: bl-297f66d8 (supersedes bl-b29b3e60)
19 lines
681 B
EmacsLisp
19 lines
681 B
EmacsLisp
// rhythm-grounding.el — Mondays at 9am, grounded against EarthCalendar(NYC),
|
|
// from a Wednesday timestamp returns the next Monday at 9am EDT.
|
|
// Wednesday 2026-05-06 00:00 UTC (1778025600) → next Monday 9am EDT
|
|
// = 2026-05-11 09:00 EDT = 2026-05-11 13:00 UTC = 1778504400.
|
|
|
|
fn run_test() -> Int {
|
|
let z: Zone = zone("America/New_York")
|
|
let cal: Calendar = earth_calendar(z)
|
|
let r: Rhythm = rhythm_weekly_at(1, 9, 0)
|
|
let after: Instant = unix_seconds(1778025600)
|
|
let next: Instant = rhythm_next_after(r, after, cal)
|
|
let next_secs: Int = instant_to_unix_seconds(next)
|
|
return next_secs
|
|
}
|
|
|
|
fn main() -> Void {
|
|
println(int_to_str(run_test()))
|
|
}
|