Skip to content

Make Mars time a service: library, JSON API, embeddable widget, AI tools, rebuilt clock - #4

Merged
emptymalei merged 2 commits into
gh-pagesfrom
claude/marstime-service
Oct 3, 2026
Merged

emptymalei merged 2 commits into
gh-pagesfrom
claude/marstime-service

Conversation

@emptymalei

@emptymalei emptymalei commented Oct 3, 2026 •

Copy link
Copy Markdown
Member

Requested by L · project thread

Before: the clock was a 2016 jQuery/Bootstrap page whose maths lived inside a DOM-bound script with no tests. It assumed TAI−UTC = 35 s, so it has run 2 s behind since 2017, and nothing else could reuse it.

After: Martian time is a small service that costs nothing to run.

  • lib/marstime.js is one ES module with no dependencies. It covers Mars24 (MSD, MTC, Ls, LMST/LTST at any longitude, Mars Year, subsolar point, rover sols) plus the InterImm calendar, clock and 25 timezones, and it uses the correct IERS leap-second table. Import it from https://cdn.jsdelivr.net/gh/InterImm/mars-clock@gh-pages/lib/marstime.js.
  • Embeddable widget for other websites. <mars-clock-card> (lib/mars-clock-card.js) is a styled card in a shadow root, with language, zone, longitude, theme, rovers and compact options. embed/ is the iframe version for sites that block scripts. The clock page has an embed builder with a live preview and a copy button. <mars-clock> remains for bare text.
  • For AI. mcp/server.mjs is a dependency-free MCP server. Add it with claude mcp add mars-time -- npx -y github:InterImm/mars-clock#gh-pages or the equivalent JSON config. Its tools are get_mars_time, interimm_to_earth, mission_sol, sol_to_earth and mars_year_dates, and … now --longitude 137.44 works as a one-shot shell command. There are also llms.txt, llms-full.txt (formulas plus the library source, generated) and api/v1/openapi.json.
  • api/v1/ holds static JSON: daily tables for 2000–2050, Mars Year and InterImm year start dates, missions, and leap seconds. It is generated by tools/build-api.mjs, and CI fails if it or llms-full.txt is stale.
  • The page (/ 中文, /en/) is rebuilt on the shared InterImm kit (https://interimm.org/kit/, live since interimm.github.io#53 merged). It has the live clock, a zone picker, local time anywhere, Earth↔Mars converters, a month calendar, a timezone table, the embed builder and developer docs. The old doc pages now redirect to its sections, and the old jQuery/Bootstrap assets (~7 MB) are removed.

How: the library is a cleaned-up port of the old marsclock.js using NASA GISS's current Mars24 constants. npm test runs 18 tests. They check NASA's 2000-01-06 worked example, the published starts of Mars Years 1, 24 and 36–39, round trips, and 400 readings recorded from the old clock. They also drive the MCP server over stdio. I checked the npx github:… install against this branch.

Changes in behaviour, all relative to the old code:

  • Times move 2 s (leap seconds).
  • The old calendar sometimes showed "day 0" or repeated a sol at a year boundary. That no longer happens.
  • Zone 24 is now 39:35 behind zone 0, as the timezone doc's geometry says. It was ahead.
  • Years keep the old code's numbering (Year 1 began on 1970-04-28; the doc called it Year 0), and the leap rule is still applied to year + 1, so no existing date changes. See the README.

The @gh-pages CDN links and the #gh-pages npx command start working once this is merged.

🤖 Generated with Claude Code

https://claude.ai/code/session_01J6QUBjpnDrbJzB9khfJfmc

- lib/marstime.js: one dependency-free ES module with Mars24 (MSD, MTC, Ls,
  local solar times, Mars Year, rover sols) and the InterImm calendar, clock
  and timezones. TAI-UTC now comes from the IERS leap-second table (37 s),
  not a fixed 35 s.
- lib/marstime.test.mjs: checks NASA's worked example, published Mars Year
  start dates, round trips, and 400 readings recorded from the old clock.
- lib/mars-clock-element.js: <mars-clock> element for other pages.
- api/v1: static JSON generated by tools/build-api.mjs; CI checks it is fresh.
- index.html, en/index.html: one bilingual page on the shared InterImm kit;
  old doc pages redirect to its sections. Old jQuery/Bootstrap assets removed.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01J6QUBjpnDrbJzB9khfJfmc
@emptymalei emptymalei self-assigned this Oct 3, 2026
…nAPI)

- lib/mars-clock-card.js: <mars-clock-card>, a styled widget in a shadow
  root (lang, zone, longitude/place, theme, rovers, compact).
- embed/: iframe version for sites that don't allow scripts.
- Embed builder with live preview on the clock page (zh and en).
- mcp/server.mjs: dependency-free MCP server over stdio, runnable with
  `npx -y github:InterImm/mars-clock#gh-pages`; also a one-shot `now` CLI.
  Tools: get_mars_time, interimm_to_earth, mission_sol, sol_to_earth,
  mars_year_dates. Tested over stdio in mcp/server.test.mjs.
- llms.txt, llms-full.txt (generated, includes formulas and library source)
  and api/v1/openapi.json.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01J6QUBjpnDrbJzB9khfJfmc
@emptymalei emptymalei changed the title Make Mars time a service: tested library, JSON API, rebuilt clock Make Mars time a service: library, JSON API, embeddable widget, AI tools, rebuilt clock Oct 3, 2026
@emptymalei
emptymalei marked this pull request as ready for review October 3, 2026 11:20
@emptymalei
emptymalei merged commit eca043d into gh-pages Oct 3, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants