mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-12 07:20:45 +00:00
Centralize date/time formatting utilities (#11831)
This commit is contained in:
@@ -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"),
|
||||
};
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user