Fix how dates are displayed (Fix #33)

This commit is contained in:
Sebastien Castiel
2024-01-09 07:45:21 -05:00
parent e891d259a5
commit a942369193

View File

@@ -29,7 +29,7 @@ export function ExpenseList({
<div <div
key={expense.id} key={expense.id}
className={cn( className={cn(
'border-t flex justify-between pl-6 pr-2 py-4 text-sm cursor-pointer hover:bg-accent', 'border-t flex justify-between pl-6 pr-2 py-4 text-sm cursor-pointer hover:bg-accent gap-1',
expense.isReimbursement && 'italic', expense.isReimbursement && 'italic',
)} )}
onClick={() => { onClick={() => {
@@ -42,10 +42,7 @@ export function ExpenseList({
</div> </div>
<div className="text-xs text-muted-foreground"> <div className="text-xs text-muted-foreground">
Paid by <strong>{getParticipant(expense.paidById)?.name}</strong> on{' '} Paid by <strong>{getParticipant(expense.paidById)?.name}</strong> on{' '}
{expense.expenseDate.toLocaleDateString('en-US', { {formatDate(expense.expenseDate)} for{' '}
dateStyle: 'medium',
})}{' '}
for{' '}
{expense.paidFor.map((paidFor, index) => ( {expense.paidFor.map((paidFor, index) => (
<Fragment key={index}> <Fragment key={index}>
{index !== 0 && <>, </>} {index !== 0 && <>, </>}
@@ -87,3 +84,10 @@ export function ExpenseList({
</p> </p>
) )
} }
function formatDate(date: Date) {
return date.toLocaleDateString('en-US', {
dateStyle: 'medium',
timeZone: 'UTC',
})
}