Calendar.js

The complete source of src/Calendar.js, exactly as it ships, in reading order. Every line is present; the file is split at its own section banners.

Calendar.js - hand-authored reactive Calendar helpers (date formatting)

// ==========================================================================
// Calendar.js - hand-authored reactive Calendar helpers (date formatting)
// ==========================================================================
//
// A small reactive mirror of the 0009 PHP `Calendar` module's human-readable
// date formatting (CalendarDate::ToHumanReadable + CalendarDateTime::ToHumanReadable
// in php_modules/0009/Calendar). Bundled here in public_html/clip for now
// alongside Maths.js; it moves down into the framework Calendar module later. (The
// framework already ships a GENERATED Calendar module - reactive/js_modules/Calendar
// - but that is the heavyweight data/codec surface, not this display helper.)
//
// The 4.0 snapshot stores its taken date as a unix timestamp (seconds), so the
// helper takes a timestamp directly. The PHP path it stands in for is
// CalendarDateTime::ToHumanReadable( CalendarDateTime::FromUnixTimestamp(ts) ),
// which yields e.g. "1st Jan 2026 14:30": ordinal day + short month name + year
// (CalendarDate), then HH:MM (CalendarTime). First consumer: the Info tab's
// Snapshot pane ("created").
// --------------------------------------------------------------------------

Reactive.Module("Calendar", () => {

  // ToHumanReadable - format a unix timestamp (seconds) as a human-readable
  // date+time string. Mirrors PHP CalendarDate::ToHumanReadable (ordinal-suffixed
  // day, short month name, year) plus CalendarTime (zero-padded HH:MM), reached
  // from a raw timestamp via FromUnixTimestamp.
  //
  // STUB: passes the timestamp through unchanged for now; the real derivation
  // (split the timestamp into y/m/d + h/m, ordinal-suffix the day, short-name the
  // month, zero-pad the time, join to "1st Jan 2026 14:30") is a later pass.
  // Shaped as a derived value (a timestamp node in, a text node out) so callers
  // bind the result directly, e.g. Input.ReadOnly(created).
  Reactive.Function("ToHumanReadable", () => {
    const timestamp = Reactive.Argument(Maths.Integer);
    return timestamp;   // stub: real "1st Jan 2026 14:30" formatting pending
  });

});