fix/pedimentos-date

This commit is contained in:
hreyes
2026-02-09 12:12:34 -06:00
parent 24c59bb2b3
commit dd77c2bc55

View File

@@ -1,7 +1,7 @@
import {
getLocalTimeZone,
parseDate,
parseTime,
import {
getLocalTimeZone,
parseDate,
parseTime,
toCalendarDateTime,
fromDate,
now,
@@ -39,7 +39,8 @@ export function loadServerDate(isoStr: string | null | undefined): string {
// Si incluye T es ISO completo, convertir a zona local
if (isoStr.includes('T')) {
const dateObj = new Date(isoStr);
return fromDate(dateObj, localTimeZone).toString();
const zonedDate = fromDate(dateObj, localTimeZone);
return `${zonedDate.year}-${String(zonedDate.month).padStart(2, '0')}-${String(zonedDate.day).padStart(2, '0')}`;
}
// Si no, asumir fecha plana YYYY-MM-DD
return isoStr.substring(0, 10);
@@ -61,8 +62,8 @@ export function addDaysLocal(dateStr: string, days: number): string {
}
export function getCurrentLocalYear(): string {
const nowZoned = now(localTimeZone);
return String(nowZoned.year).slice(-2);
const nowZoned = now(localTimeZone);
return String(nowZoned.year).slice(-2);
}
export function getCurrentLocalDate(): string {
@@ -70,6 +71,6 @@ export function getCurrentLocalDate(): string {
}
export function getCurrentLocalTime(): string {
const nowZoned = now(localTimeZone);
return `${String(nowZoned.hour).padStart(2, '0')}:${String(nowZoned.minute).padStart(2, '0')}`;
const nowZoned = now(localTimeZone);
return `${String(nowZoned.hour).padStart(2, '0')}:${String(nowZoned.minute).padStart(2, '0')}`;
}