Centralize date/time formatting utilities (#11831)

This commit is contained in:
max
2026-02-08 04:53:31 -08:00
committed by GitHub
parent 74fbbda283
commit a1123dd9be
77 changed files with 1508 additions and 1075 deletions

View File

@@ -1,11 +1,12 @@
import type { Command } from "commander";
import type { NodesRpcOpts } from "./types.js";
import { formatTimeAgo } from "../../infra/format-time/format-relative.ts";
import { defaultRuntime } from "../../runtime.js";
import { renderTable } from "../../terminal/table.js";
import { shortenHomeInString } from "../../utils.js";
import { parseDurationMs } from "../parse-duration.js";
import { getNodesTheme, runNodesCommand } from "./cli-utils.js";
import { formatAge, formatPermissions, parseNodeList, parsePairingList } from "./format.js";
import { formatPermissions, parseNodeList, parsePairingList } from "./format.js";
import { callGatewayCli, nodesCallOpts, resolveNodeId } from "./rpc.js";
function formatVersionLabel(raw: string) {
@@ -178,7 +179,7 @@ export function registerNodesStatusCommands(nodes: Command) {
const connected = n.connected ? ok("connected") : muted("disconnected");
const since =
typeof n.connectedAtMs === "number"
? ` (${formatAge(Math.max(0, now - n.connectedAtMs))} ago)`
? ` (${formatTimeAgo(Math.max(0, now - n.connectedAtMs))})`
: "";
return {
@@ -361,7 +362,7 @@ export function registerNodesStatusCommands(nodes: Command) {
IP: r.remoteIp ?? "",
Requested:
typeof r.ts === "number"
? `${formatAge(Math.max(0, now - r.ts))} ago`
? formatTimeAgo(Math.max(0, now - r.ts))
: muted("unknown"),
Repair: r.isRepair ? warn("yes") : "",
}));
@@ -397,7 +398,7 @@ export function registerNodesStatusCommands(nodes: Command) {
IP: n.remoteIp ?? "",
LastConnect:
typeof lastConnectedAtMs === "number"
? `${formatAge(Math.max(0, now - lastConnectedAtMs))} ago`
? formatTimeAgo(Math.max(0, now - lastConnectedAtMs))
: muted("unknown"),
};
});