/** * Highcharts-style DateTime Formatter Utility for Charts (Functional) * * This utility provides Highcharts-compatible datetime formatting for charts. * It intelligently formats timestamps based on the data range and supports * custom format strings similar to Highcharts' dateTimeLabelFormats. */ export declare const TIME_UNITS: { readonly millisecond: 1; readonly second: 1000; readonly minute: 60000; readonly hour: 3600000; readonly day: 86400000; readonly week: 604800000; readonly month: 2592000000; readonly year: 31536000000; }; export type TimeUnit = keyof typeof TIME_UNITS; export declare const DEFAULT_DATE_TIME_FORMATS: Record; export interface DateTimeFormatterConfig { useUTC?: boolean; customFormats?: Partial>; startOfWeek?: number; } /** * Parse and validate a timestamp value * Handles: numbers, numeric strings, ISO strings, seconds vs milliseconds */ export declare function parseTimestamp(value: string | number): number | null; /** * Determines the most appropriate time unit based on data range */ export declare function getTimeUnit(dataRange: number): TimeUnit; /** * Get time unit from an array of timestamps */ export declare function getTimeUnitFromData(timestamps: number[]): TimeUnit; /** * Normalize timestamp to the nearest time unit boundary * This ensures consistent tick positioning like Highcharts */ export declare function normalizeTimestamp(timestamp: number, timeUnit: TimeUnit, config?: DateTimeFormatterConfig): number; /** * Formats a timestamp according to a format string (Highcharts-style) * * Format tokens: * - %Y: 4-digit year (2024) * - %y: 2-digit year (24) * - %m: 2-digit month (01-12) * - %b: Short month name (Jan) * - %B: Full month name (January) * - %d: 2-digit day (01-31) * - %e: Day without leading zero (1-31) * - %H: 2-digit hour 24h (00-23) * - %I: 2-digit hour 12h (01-12) * - %M: 2-digit minute (00-59) * - %S: 2-digit second (00-59) * - %L: Milliseconds (000-999) * - %p: AM/PM * - %A: Full weekday name (Monday) * - %a: Short weekday name (Mon) * - %%: Literal % character */ export declare function dateFormat(formatString: string, timestamp: number, config?: DateTimeFormatterConfig): string; /** * Get the appropriate date format for a given time unit */ export declare function getDateFormat(timeUnit: TimeUnit, config?: DateTimeFormatterConfig): string; /** * Get optimal tick interval to prevent cluttered axes * Returns recommended number of milliseconds between ticks */ export declare function getOptimalTickInterval(dataRange: number, maxTicks?: number): { interval: number; unit: TimeUnit; }; /** * Generate evenly spaced tick values for a time range * This prevents cluttered axes by ensuring consistent spacing */ export declare function generateTickValues(minTimestamp: number, maxTimestamp: number, maxTicks?: number, config?: DateTimeFormatterConfig): number[]; /** * Generate ticks at a custom interval (in milliseconds) * Useful for forcing specific tick spacing (e.g., every 6 hours) */ export declare function generateTicksAtInterval(minTimestamp: number, maxTimestamp: number, intervalMs: number, timeUnit?: TimeUnit, config?: DateTimeFormatterConfig): number[]; /** * Create a basic formatter function for a specific time unit */ export declare function createFormatter(timeUnit: TimeUnit, config?: DateTimeFormatterConfig): (value: number) => string; /** * Create a formatter function for chart axes with auto time unit detection */ export declare function createAxisFormatter(timestamps: number[], config?: DateTimeFormatterConfig): (value: number) => string; /** * Create a smart formatter that shows date on day change, time otherwise * Similar to Highcharts' smart datetime formatting */ export declare function createSmartFormatter(timestamps: number[], showYear?: boolean, config?: DateTimeFormatterConfig): (value: number) => string; /** * Create an alternating date/time formatter * Shows date on even ticks, time on odd ticks (e.g., "1 Oct", "12:00", "2 Oct", "12:00") */ export declare function createAlternatingFormatter(ticks: number[], dateFormatStr?: string, timeFormatStr?: string, config?: DateTimeFormatterConfig): (value: number) => string; /** * Format multiple timestamps */ export declare function formatMultiple(timestamps: number[], timeUnit?: TimeUnit, config?: DateTimeFormatterConfig): string[]; /** * Generate date-only ticks (for Charts dateOnly mode) * Returns ticks at day boundaries with date-only labels */ export declare function createDateOnlyTicksAndFormatter(minTimestamp: number, maxTimestamp: number, maxTicks?: number, showYear?: boolean, config?: DateTimeFormatterConfig): { ticks: number[]; formatter: (value: number) => string; }; /** * Generate time-only ticks spanning the entire data range * Shows times at regular intervals (e.g., every 15 minutes, 1 hour, etc.) */ export declare function createTimeOnlyTicksAndFormatter(minTimestamp: number, maxTimestamp: number, intervalMinutes?: number, maxTicks?: number, config?: DateTimeFormatterConfig): { ticks: number[]; formatter: (value: number) => string; }; /** * Generate ticks with alternating date and time labels * Pattern: Date, Time, Date, Time, etc. */ export declare function createDateTimeAlternatingTicksAndFormatter(minTimestamp: number, maxTimestamp: number, intervalMs?: number, showYear?: boolean, maxTicks?: number, config?: DateTimeFormatterConfig): { ticks: number[]; formatter: (value: number) => string; }; /** * All-in-one helper: Generate ticks and create alternating formatter */ export declare function createAlternatingTicksAndFormatter(minTimestamp: number, maxTimestamp: number, intervalMs: number, options?: { timeUnit?: TimeUnit; dateFormat?: string; timeFormat?: string; }, config?: DateTimeFormatterConfig): { ticks: number[]; formatter: (value: number) => string; }; /** * Create a dynamic tick generator that adapts to available width * This prevents tick collision by adjusting density based on chart width */ export declare function createResponsiveTicksAndFormatter(minTimestamp: number, maxTimestamp: number, chartWidthPx: number, avgLabelWidthPx?: number, mode?: 'dateOnly' | 'timeOnly' | 'alternating' | 'smart', showYear?: boolean, config?: DateTimeFormatterConfig): { ticks: number[]; formatter: (value: number) => string; };