- ✅ Ticket 1.1: Estructura Clean Architecture en backend - ✅ Ticket 1.2: Schemas Zod compartidos - ✅ Ticket 1.3: Refactorización drugs.ts (1362 → 8 archivos modulares) - ✅ Ticket 1.4: Refactorización procedures.ts (3583 → 6 archivos modulares) - ✅ Ticket 1.5: Eliminación de duplicidades (~50 líneas) Cambios principales: - Creada estructura Clean Architecture en backend/src/ - Schemas Zod compartidos en backend/src/shared/schemas/ - Refactorización modular de drugs y procedures - Utilidades genéricas en src/utils/ (filter, validation) - Eliminados scripts obsoletos y documentación antigua - Corregidos errores: QueryClient, import test-error-handling - Build verificado y funcionando correctamente
65 lines
1.6 KiB
JavaScript
65 lines
1.6 KiB
JavaScript
const dateLongFormatter = (pattern, formatLong) => {
|
|
switch (pattern) {
|
|
case "P":
|
|
return formatLong.date({ width: "short" });
|
|
case "PP":
|
|
return formatLong.date({ width: "medium" });
|
|
case "PPP":
|
|
return formatLong.date({ width: "long" });
|
|
case "PPPP":
|
|
default:
|
|
return formatLong.date({ width: "full" });
|
|
}
|
|
};
|
|
|
|
const timeLongFormatter = (pattern, formatLong) => {
|
|
switch (pattern) {
|
|
case "p":
|
|
return formatLong.time({ width: "short" });
|
|
case "pp":
|
|
return formatLong.time({ width: "medium" });
|
|
case "ppp":
|
|
return formatLong.time({ width: "long" });
|
|
case "pppp":
|
|
default:
|
|
return formatLong.time({ width: "full" });
|
|
}
|
|
};
|
|
|
|
const dateTimeLongFormatter = (pattern, formatLong) => {
|
|
const matchResult = pattern.match(/(P+)(p+)?/) || [];
|
|
const datePattern = matchResult[1];
|
|
const timePattern = matchResult[2];
|
|
|
|
if (!timePattern) {
|
|
return dateLongFormatter(pattern, formatLong);
|
|
}
|
|
|
|
let dateTimeFormat;
|
|
|
|
switch (datePattern) {
|
|
case "P":
|
|
dateTimeFormat = formatLong.dateTime({ width: "short" });
|
|
break;
|
|
case "PP":
|
|
dateTimeFormat = formatLong.dateTime({ width: "medium" });
|
|
break;
|
|
case "PPP":
|
|
dateTimeFormat = formatLong.dateTime({ width: "long" });
|
|
break;
|
|
case "PPPP":
|
|
default:
|
|
dateTimeFormat = formatLong.dateTime({ width: "full" });
|
|
break;
|
|
}
|
|
|
|
return dateTimeFormat
|
|
.replace("{{date}}", dateLongFormatter(datePattern, formatLong))
|
|
.replace("{{time}}", timeLongFormatter(timePattern, formatLong));
|
|
};
|
|
|
|
export const longFormatters = {
|
|
p: timeLongFormatter,
|
|
P: dateTimeLongFormatter,
|
|
};
|