Hare, the minimalist systems programming language, tests its standard library’s datetime and time::chrono modules by implementing a Martian business calendar. Developer Byron Torres built hare-mbc, a library modeling the Martian Business Calendar (MBC) by Bruce Mills. This choice stresses the library’s design under exotic constraints, revealing potential flaws early in development.
Hare prioritizes simplicity and safety over C’s pitfalls. Its datetime module handles Earth-based Gregorian calendars with mathematical precision. Torres extends this to Mars, where a sol equals one Martian day—roughly 24 hours 37 minutes. MBC years span 665 or 672 sols, double Earth’s 365.25 days on average. It divides into 24 months of 28 sols each, with the final month occasionally skipping an intercalary leap week instead of inserting a leap day.
Leap weeks preserve weekday consistency across months and years, unlike Earth’s leap days that shift weekends. This appeals for business calendars, where fixed weekly cycles matter—think trading days uninterrupted by holidays. MBC’s 76-year cycle totals 50,813 sols, computed via lookup table rather than formulas, simplifying edge-case handling. Torres claims this proved easier than Gregorian logic, a win for Hare’s modular chrono abstractions.
Why Martian Calendars Matter for Software
Exotic chronologies expose stdlib weaknesses. Finance relies on business day calculations for options pricing, settlements, and risk models—off-by-one errors cost millions. NASA’s Mars missions demand sol tracking; poor implementations led to real failures, like the 1999 Mars Climate Orbiter loss from unit mismatches. Hare-mbc benchmarks time::chrono against these: does it modularize epochs, durations, and zones scalably?
Hare’s dev pace accelerates. Drew DeVault focuses on Helios, his Wayland compositor rewritten in Hare, hammering the language with production code. Recent additions like @threadlocal stem from this scrutiny. Torres maintains datetime modules, using hare-mbc to validate choices like abstract chronologies over rigid structs.
Skepticism warranted: hare-mbc remains incomplete and untested. Demos rely on a forked stdlib, pending merge. Prior Hare blog posts detail chronology design, emphasizing composability—mbc::new takes a chrono::MTC epoch, year, month, etc. No parsing or arithmetic yet, keeping it lean.
Hands-On Demo
Install Hare from harelang.org. Generate docs:
$ haredoc -Fhtml time::mbc
Sample code imports modules and constructs MBC datetimes:
use time;
use time::mbc;
use time::chrono;
use datetime;
use fmt;
// MBC epoch
let epoch = mbc::new(chrono::MTC, 0)!;
// Unix epoch equivalent
let unix = mbc::new(chrono::MTC, 0, 0191, 20, 23, 07, 06, 01, 057366670)!;
// Example birthday
let birt = mbc::new(chrono::MTC, 0, 0207, 11, 16, 08, 49, 27, 279563480)!;
These map Earth timestamps to Martian coords. Epoch aligns MBC year 0; unix translates 1970-01-01 UTC. Outputs reveal sol offsets—e.g., Unix epoch hits MBC year 191, month 20.
Implications cut deep. Hare’s stdlib aims for unbreakable time handling, vital for finance (crypto exchanges track UTC precisely), aerospace, and IoT. MBC proves the abstraction holds under weird rules, but production needs battle-testing. Forked stdlib flags immaturity—Hare launched 2022, still maturing. Watch for merges; if robust, it positions Hare as a C killer for time-sensitive apps. Developers: clone hare-mbc, hack Martian trades. Just don’t bet real sats on untested code.