Skip to content

Mothership dashboard: drop American date format, use international short weekday + month-day-year + 24h time #438

@DKuleshov

Description

@DKuleshov

Problem

Mothership dashboard renders timestamps via plain Date.prototype.toLocaleString(), which honours the browser's locale - on en-US browsers that produces American MM/DD/YYYY with 12h AM/PM (5/19/2026, 1:26 PM). Mixed locales between users + the rest of the dotbot client UI which uses an explicit international format makes timestamps inconsistent and ambiguous.

Target format

Tue, May 19 2026 13:26
  • Short weekday (Tue)
  • Short month name (May) - month-day-year ordering matches the existing client decisions.js convention (month-short, day, year)
  • 24h time, leading zeros on hour + minute
  • No seconds, no AM/PM, no comma between date and time

Existing client convention to match

core/ui/static/modules/decisions.js _friendlyDate:

new Date(iso).toLocaleDateString(undefined, { month: 'short', day: 'numeric', year: 'numeric' });

That gives May 19, 2026 (no weekday, no time). Mothership dashboard needs the longer form with weekday + time. Same option-bag style, just more fields.

Where to fix

  • server/src/Dotbot.Server/wwwroot/js/dashboard.js line 289 - inst.createdAt rendered via new Date(inst.createdAt).toLocaleString(). Replace with an Intl.DateTimeFormat-based helper.
  • server/src/Dotbot.Server/wwwroot/js/dashboard.js line 817 - Last refresh: ${new Date().toLocaleTimeString()} renders 12h time on en-US browsers. Switch to 24h via the same helper or a hour12: false formatter.
  • Any other toLocaleString() / toLocaleDateString() / toLocaleTimeString() calls in server/src/Dotbot.Server/wwwroot/ that surface timestamps. Sweep with grep -rn toLocale wwwroot/.
  • If the dashboard has any server-rendered timestamps in Razor / .cshtml, format them server-side with IFormatProvider matching the JS shape so refresh-vs-initial-render look identical.

Suggested helper

One place to own the format. Drop in wwwroot/js/utils.js (or wherever shared dashboard helpers live):

const _dashboardDateFmt = new Intl.DateTimeFormat('en-GB', {
    weekday: 'short',
    month: 'short',
    day: 'numeric',
    year: 'numeric',
    hour: '2-digit',
    minute: '2-digit',
    hour12: false,
});

// "Tue, May 19, 2026, 13:26" - en-GB gives day-month-year by default;
// post-process to month-day order without commas to match the target.
function formatDashboardDateTime(iso) {
    if (!iso) return '-';
    const d = new Date(iso);
    if (isNaN(d)) return '-';
    const parts = _dashboardDateFmt.formatToParts(d);
    const get = type => parts.find(p => p.type === type)?.value ?? '';
    return `${get('weekday')}, ${get('month')} ${get('day')} ${get('year')} ${get('hour')}:${get('minute')}`;
}

formatToParts decouples output from locale-specific punctuation / ordering. Caller just passes an ISO string.

Acceptance

  • All visible timestamps in the Mothership dashboard render as Tue, May 19 2026 13:26 regardless of browser locale.
  • No remaining toLocaleString() / toLocaleDateString() / toLocaleTimeString() calls on Date objects under server/src/Dotbot.Server/wwwroot/ for user-visible timestamps. (Calls on numbers, e.g. tokens.toLocaleString() for thousands-separators, are fine.)
  • Auto-refresh footer shows 24h time.
  • Helper has a unit-style sanity test in whatever JS-test setup the dashboard uses (or a Razor smoke if no JS tests).

Out of scope

  • Timezone selection / per-user TZ preference - format stays browser-local. Future enhancement if needed.
  • Client outpost UI - already uses the short-month convention; only touch if the same surface drifts.
  • Internationalisation beyond English month/weekday names - dotbot's UI is currently English only.

Files likely touched

  • server/src/Dotbot.Server/wwwroot/js/dashboard.js
  • server/src/Dotbot.Server/wwwroot/js/utils.js (new helper) or wherever shared helpers live
  • server/src/Dotbot.Server/wwwroot/css/*.css only if column widths need adjusting for the longer string

Metadata

Metadata

Labels

bugSomething isn't working

Projects

Status
Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions