@kya-os/cli
Version:
CLI for MCP-I setup and management
30 lines • 1 kB
JavaScript
/**
* Time formatting utilities for CLI display
*/
/**
* Format a receipt timestamp for display.
* Handles both Unix timestamps (numbers) and ISO 8601 strings gracefully.
*
* @param ts - Timestamp as either Unix seconds (number) or ISO 8601 string
* @returns Formatted ISO 8601 string or original value if unparseable
*/
export function formatReceiptTs(ts) {
if (typeof ts === "number") {
// Assume Unix timestamp in seconds
const d = new Date(ts * 1000);
return Number.isNaN(d.getTime()) ? String(ts) : d.toISOString();
}
// Try to parse as ISO 8601 or other date string
const d = new Date(ts);
return Number.isNaN(d.getTime()) ? String(ts) : d.toISOString();
}
/**
* Check if a timestamp is using the deprecated numeric format
*
* @param ts - Timestamp to check
* @returns true if the timestamp is a deprecated numeric format
*/
export function isDeprecatedTimestamp(ts) {
return typeof ts === "number";
}
//# sourceMappingURL=time.js.map