diff --git a/src/lib/utils.ts b/src/lib/utils.ts index bd0c391..0b799de 100644 --- a/src/lib/utils.ts +++ b/src/lib/utils.ts @@ -4,3 +4,13 @@ import { twMerge } from "tailwind-merge" export function cn(...inputs: ClassValue[]) { return twMerge(clsx(inputs)) } + +export function formatDateDDMMYYYY(dateString: string): string { + if (!dateString) return ''; + const date = new Date(dateString); + if (isNaN(date.getTime())) return dateString; + const day = String(date.getDate()).padStart(2, '0'); + const month = String(date.getMonth() + 1).padStart(2, '0'); + const year = date.getFullYear(); + return `${day}-${month}-${year}`; +} diff --git a/src/sections/Dashboard.tsx b/src/sections/Dashboard.tsx index ab35f25..670a714 100644 --- a/src/sections/Dashboard.tsx +++ b/src/sections/Dashboard.tsx @@ -13,6 +13,7 @@ import { import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'; import { Badge } from '@/components/ui/badge'; import { Button } from '@/components/ui/button'; +import { formatDateDDMMYYYY } from '@/lib/utils'; import type { Vista, Internacion, Paciente, Cultivo } from '@/types'; interface DashboardProps { @@ -209,7 +210,7 @@ export function Dashboard({ {paciente ? `${paciente.apellido}, ${paciente.nombre}` : 'Paciente no encontrado'}
- Ingreso: {internacion.fechaIngreso} + Ingreso: {formatDateDDMMYYYY(internacion.fechaIngreso)}
Fecha de Ingreso
-{internacion.fechaIngreso}
+{formatDateDDMMYYYY(internacion.fechaIngreso)}
Diagnóstico de Ingreso
diff --git a/src/sections/Internaciones.tsx b/src/sections/Internaciones.tsx index 43c3626..8e9ab1c 100644 --- a/src/sections/Internaciones.tsx +++ b/src/sections/Internaciones.tsx @@ -8,6 +8,7 @@ import { Label } from '@/components/ui/label'; import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogTrigger } from '@/components/ui/dialog'; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select'; import type { Internacion, Paciente, Cama, Area, Evolucion, Laboratorio, Cultivo } from '@/types'; +import { formatDateDDMMYYYY } from '@/lib/utils'; interface InternacionesProps { internaciones: Internacion[]; @@ -333,7 +334,7 @@ export function Internaciones({Paciente:
{paciente.apellido}, {paciente.nombre}
DNI: {paciente.dni}
-Ingreso: {internacion.fechaIngreso}
+Ingreso: {formatDateDDMMYYYY(internacion.fechaIngreso)}
Diagnóstico: {internacion.diagnosticoIngreso}
Médico: {internacion.medicoIngresante}