@salesforce/b2c-tooling-sdk / operations/metrics / parseMetricsBound
Function: parseMetricsBound()
parseMetricsBound(
value,now):Date
Defined in: packages/b2c-tooling-sdk/src/operations/metrics/index.ts:208
Parses a single metrics time bound (from or to) into a Date.
This is the shared bound parser for the CLI metrics get command and the MCP metrics_get tool. It resolves a single bound in isolation; deriving the companion bound and applying the 24-hour default window is the job of resolveMetricsWindow.
Parameters
value
The bound: a Date, epoch milliseconds, a relative duration (5m/1h/2d, relative to now), or an ISO 8601 timestamp
now
Date = ...
Reference time for relative durations (defaults to the current time; injectable for deterministic tests)
Returns
Date
The resolved Date
Throws
TypeError if a string value is neither a valid relative duration nor a parseable ISO 8601 timestamp
Example
const from = parseMetricsBound('2d'); // 2 days ago
const to = parseMetricsBound('2026-01-25T12:00:00Z');
await getSalesMetrics(client, tenantId, {from, to});