add Calendar + CalendarTime + Rhythm + LocalDate/Time as first-class
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)
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
// cycle-30hr.el — CycleCalendar with a 30-hour period.
|
||||
// Two CalendarTimes 15 hours apart should have cycle_phase differ by 0.5.
|
||||
// We compare phases via float subtraction with format_float for determinism.
|
||||
|
||||
fn run_test() -> String {
|
||||
let period: Duration = 30.hours
|
||||
let cal: Calendar = cycle_calendar(period)
|
||||
let base: Instant = unix_seconds(0)
|
||||
let later: Instant = base + 15.hours
|
||||
let ct1: CalendarTime = in_calendar(base, cal)
|
||||
let ct2: CalendarTime = in_calendar(later, cal)
|
||||
let p1: Float = cal_cycle_phase(ct1)
|
||||
let p2: Float = cal_cycle_phase(ct2)
|
||||
let diff: Float = p2 - p1
|
||||
return format_float(diff, 1)
|
||||
}
|
||||
|
||||
fn main() -> Void {
|
||||
println(run_test())
|
||||
}
|
||||
Reference in New Issue
Block a user