7cfd14ae09
start_time é naive; o node-pg o serializa no fuso do container (America/Sao_Paulo). Exibir no fuso do NAVEGADOR (ex.: UTC-4) mostrava -1h (09:30 -> 08:30). Agora o frontend formata SEMPRE em America/Sao_Paulo (o mesmo frame do armazenamento), recuperando o wall-clock literal para qualquer navegador: - utils/appTime.ts: STORAGE_TZ + fmtHora/fmtDataCurta/fmtDataHora. - FullCalendar timeZone="America/Sao_Paulo". - AgendaDetailModal (card "Data e hora" + histórico) e AgendaView (interesses) usam os helpers. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
19 lines
1.2 KiB
TypeScript
19 lines
1.2 KiB
TypeScript
// Fuso de REFERÊNCIA do armazenamento. As colunas de horário (agendamentos.start_time)
|
|
// são `timestamp` naive; o backend (container) roda em America/Sao_Paulo, então o node-pg
|
|
// serializa o wall-clock naive nesse fuso. Para exibir o horário LITERAL (o mesmo que a
|
|
// Secretária ofereceu/gravou) em qualquer navegador, formatamos SEMPRE neste fuso — e não
|
|
// no fuso local do navegador (que causaria o deslocamento de ±1h).
|
|
export const STORAGE_TZ = 'America/Sao_Paulo';
|
|
|
|
const D = (v?: string | number | Date | null) => (v === null || v === undefined || v === '' ? null : new Date(v));
|
|
|
|
export const fmtHora = (v?: string | number | Date | null): string => {
|
|
const d = D(v); return d ? d.toLocaleTimeString('pt-BR', { hour: '2-digit', minute: '2-digit', timeZone: STORAGE_TZ }) : '—';
|
|
};
|
|
export const fmtDataCurta = (v?: string | number | Date | null): string => {
|
|
const d = D(v); return d ? d.toLocaleDateString('pt-BR', { weekday: 'short', day: 'numeric', month: 'short', timeZone: STORAGE_TZ }) : '—';
|
|
};
|
|
export const fmtDataHora = (v?: string | number | Date | null): string => {
|
|
const d = D(v); return d ? d.toLocaleString('pt-BR', { day: '2-digit', month: '2-digit', hour: '2-digit', minute: '2-digit', timeZone: STORAGE_TZ }) : '—';
|
|
};
|