UNPKG

@kya-os/mcp-i

Version:

The TypeScript MCP framework with identity features built-in

81 lines (80 loc) 2.63 kB
/** * Time Formatting Utilities * * Provides human-readable time formatting for intervals and durations. * Used by audit logging and other time-based features. * * @example * ```typescript * import { formatTimeInterval } from './utils/time'; * * formatTimeInterval(86400000); // "daily" * formatTimeInterval(3600000); // "hourly" * formatTimeInterval(7200000); // "2-hourly" * formatTimeInterval(123456); // "123456ms" * ``` */ /** * Common time intervals in milliseconds * * These constants provide standard time intervals that can be used * throughout the codebase for consistency. * * @example * ```typescript * const dailyRotation = TIME_INTERVALS.DAY; // 86400000 * const hourlyCheck = TIME_INTERVALS.HOUR; // 3600000 * ``` */ export declare const TIME_INTERVALS: { /** 1 second in milliseconds */ readonly SECOND: 1000; /** 1 minute in milliseconds */ readonly MINUTE: number; /** 1 hour in milliseconds */ readonly HOUR: number; /** 1 day in milliseconds */ readonly DAY: number; /** 1 week in milliseconds */ readonly WEEK: number; }; /** * Format milliseconds into human-readable interval string * * Converts a time interval in milliseconds to a descriptive string * that's easier for humans to understand and for logging purposes. * * **Format Priority:** * 1. Weekly intervals (e.g., "weekly", "2-weekly") * 2. Daily intervals (e.g., "daily", "3-daily") * 3. Hourly intervals (e.g., "hourly", "12-hourly") * 4. Minute intervals (e.g., "minutely", "30-minutely") * 5. Second intervals (e.g., "every-second", "5-secondly") * 6. Custom milliseconds (e.g., "123456ms") * * @param ms - Milliseconds to format (undefined returns "unknown") * @returns Human-readable interval string * * @example Standard intervals * ```typescript * formatTimeInterval(86400000); // "daily" * formatTimeInterval(3600000); // "hourly" * formatTimeInterval(604800000); // "weekly" * formatTimeInterval(60000); // "minutely" * ``` * * @example Multiple intervals * ```typescript * formatTimeInterval(172800000); // "2-daily" (2 days) * formatTimeInterval(7200000); // "2-hourly" (2 hours) * formatTimeInterval(1800000); // "30-minutely" (30 minutes) * ``` * * @example Edge cases * ```typescript * formatTimeInterval(undefined); // "unknown" * formatTimeInterval(123456); // "123456ms" (custom) * formatTimeInterval(1000); // "every-second" * ``` */ export declare function formatTimeInterval(ms: number | undefined): string;