Files
el/tests/calendar/examples/mars-calendar.el
T
Will Anderson ed564b6dda 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)
2026-05-02 13:21:43 -05:00

22 lines
776 B
EmacsLisp

// mars-calendar.el MarsCalendar uses sol period 88775.244 seconds.
// Two instants exactly one sol apart should differ by 1 in sol number.
fn run_test() -> Int {
let cal: Calendar = mars_calendar()
let base: Instant = unix_seconds(0)
// 88775.244 s * 1e9 nanos = 88775244000000 nanos
let one_sol_ns: Int = 88775244000000
let one_sol: Duration = el_duration_from_nanos(one_sol_ns)
let later: Instant = base + one_sol
let ct1: CalendarTime = in_calendar(base, cal)
let ct2: CalendarTime = in_calendar(later, cal)
let sol1: String = cal_format(ct1, "%sol")
let sol2: String = cal_format(ct2, "%sol")
let diff: Int = str_to_int(sol2) - str_to_int(sol1)
return diff
}
fn main() -> Void {
println(int_to_str(run_test()))
}