import { DateValue, DateError } from '../interfaces'; import * as i0 from "@angular/core"; export declare class DateTimeUtil { private readonly userTimezone; constructor(); /** * Verifica si la configuración de timezone ya está en localStorage * Usado en APP_INITIALIZER para evitar consultas duplicadas */ isTimezoneConfigLoaded(): boolean; /** * Guarda la configuración de timezone en localStorage * Llamado por Shell y por MF cuando corre standalone */ setTimezoneConfig(defaultTZ: string, timezoneLabel: string): void; /** * Obtiene la timezone IANA del back (ej: "America/Santiago") * Si no está configurada, retorna el fallback */ getDefaultTZ(): string; /** * Obtiene el label base del timezone del back (ej: "Hora de Chile") * Si no está configurado, retorna el fallback */ private getTimezoneBaseLabel; /** * Construye el label completo del flag de timezone * Ejemplo: "Hora de Chile" + "UTC-4" → "Hora de Chile (UTC-4)" * Retorna string vacío si isoString es null/undefined */ getTimezoneLabel(isoString: string | null | undefined): string; /** * Convierte cualquier formato de entrada a ISO 8601. * type explícito SIEMPRE tiene prioridad sobre attributeName. */ toISO(value: string | Date | number | DateValue, type?: 'date' | 'datetime', attributeName?: string): string | DateError; /** * Convierte ISO a dd/MM/yyyy para mostrar en pantalla. * Retorna DateError si el string es inválido — nunca silencia errores. */ toDisplay(isoString: string): string | DateError; /** * Convierte ISO a dd/MM/yyyy HH:mm para mostrar en pantalla con hora. * Retorna DateError si el string es inválido — nunca silencia errores. */ toDisplayWithTime(isoString: string): string | DateError; /** * Convierte ISO a dd/MM/yyyy o dd/MM/yyyy HH:mm automáticamente. * Muestra hora solo si la timezone del backend difiere de la del usuario. * Retorna DateError si el string es inválido — nunca silencia errores. */ toDisplayAuto(isoString: string): string | DateError; /** * Extrae el offset ±HH:MM del ISO string. */ getTimezoneOffset(isoString: string | null | undefined): string | null; /** * Convierte offset ±HH:MM a formato legible "UTC-4". */ getBackendOffset(isoString: string | null | undefined): string; /** * Compara timezone del ISO (back) con la del usuario (browser). * true = misma zona → no mostrar flag * false = diferente → mostrar flag */ isSameTimezone(isoString: string | null | undefined): boolean; /** * Convierte ISO a Date object para pintarlo en MatDatepicker. * * IMPORTANTE: Extrae componentes directamente del ISO string sin ajuste de timezone. * Esto garantiza que: * - El picker muestra la fecha correcta (ej: 30/12/1993) * - getDate() devuelve el día correcto al guardar (ej: 30) * - No hay cambio de día por diferencia de timezone entre backend y usuario * * Ejemplo: * - ISO: "1993-12-30T00:00:00.000-04:00" (Chile UTC-4) * - parsed.day = 30 * - new Date(1993, 11, 30, 0, 0, 0, 0) → picker muestra 30/12/1993 ✅ * - date.getDate() → 30 siempre ✅ */ toDateObject(isoString: string): Date | DateError; /** * Convierte ISO 8601 a Date object para MatDatepicker, garantizando que muestre la fecha exacta del backend. * * IMPORTANTE: Ahora que toDateObject() extrae componentes directamente del ISO string, * este método simplemente delega a toDateObject() sin necesidad de ajustes adicionales. * * @param isoString ISO 8601 con offset (ej: "2026-05-20T00:00:00.000-04:00") * @returns Date object que se mostrará correctamente en MatDatepicker */ toDateObjectForDatepicker(isoString: string): Date | DateError; /** * Convierte el Date object del MatDatepicker a ISO 8601. * NUNCA usa hora actual — extrae exactamente lo que trae el Date object. */ fromDatepicker(dateValue: Date | string, type: 'date' | 'datetime', attributeName?: string): string | DateError; /** * Convierte Date del datepicker a ISO datetime con T00:00:00.000 * para campos date-only que el backend espera como datetime. * * Extrae año/mes/día directamente sin setHours() para evitar * cambio de día por ajuste de timezone. * * Uso: birthDate, initialDate, endDate (campos que tienen "Date" en el nombre * pero el backend espera datetime con offset) * * @param dateValue Date object del datepicker * @returns ISO string con formato "YYYY-MM-DDTHH:mm:ss.sssZ±HH:mm" */ fromDatepickerDateOnly(dateValue: Date): string | DateError; /** * Infiere 'date' o 'datetime' desde el sufijo del nombre del atributo. */ inferTypeFromAttributeName(attributeName: string): 'date' | 'datetime' | null; /** * Infiere la regla de hora automática para campos de vigencia. * Solo INFORMA la regla — el componente de negocio aplica la hora. * * 'start' → usar T00:00:00.000 (inicio del día) * 'end' → usar T23:59:59.999 (fin del día) * 'preserve'→ usar la hora que viene en el input */ inferTimeRule(attributeName: string): 'start' | 'end' | 'preserve'; /** * Convierte valor del formulario/datepicker a ISO 8601. * Aplica reglas automáticas según el nombre del atributo: * - Start → hora actual si es hoy, 00:00 si es futuro * - End → 23:59:59.999 * - Otros → preservar hora del input * * Centralizado aquí para no duplicar en cada componente/MF. * * @param dateValue Valor del datepicker (Date o string) * @param type 'date' o 'datetime' * @param attributeName Nombre del atributo (para inferir regla de hora) * @returns ISO string con offset del backend, o undefined si inválido */ /** * Parsea un string en formato dd/MM/yyyy a Date object * @param dateString String en formato dd/MM/yyyy * @returns Date object o null si no es válido */ private parseDdMmYyyy; convertDateToISO(dateValue: any, type: 'date' | 'datetime', attributeName?: string): string | undefined; /** * Para campos effectiveStartDateTime: * - Hoy → hora actual en TZ del back (no del usuario) * - Futuro → 00:00:00.000 en TZ del back * * @param selectedDate Fecha seleccionada por el usuario * @returns ISO string con offset del backend o DateError */ fromDatepickerEffectiveStart(selectedDate: Date): string | DateError; private parseAny; private parseComponents; private formatISO; private currentUserOffset; /** * Obtiene la fecha actual expresada en la timezone del backend. * Usar para calcular estado de vigencia (activo/inactivo). * @param {string} backIsoSample - Valor ISO de ejemplo del backend (contiene el offset) * @returns {Date} Fecha actual en la timezone del backend */ getNowInBackTimezone(isoSample?: string): Date; /** * Construye headers dinámicos con timezone para columnas de vigencia. * Muta las columnas existentes sin reemplazar el array. * Solo ejecuta si la timezone del backend es diferente a la del usuario. * @param {any[]} columns - Array de columnas * @param {string} backendIsoSample - Primer valor ISO de una columna de vigencia */ buildTableHeaders(columns: any[], backendIsoSample: string): void; /** * Elimina tags HTML de un string. * @param {string} html - String con HTML * @returns {string} String sin HTML */ private stripHtml; private err; private getDefaultTZOffset; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵprov: i0.ɵɵInjectableDeclaration; }