mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-25 10:51:13 -05:00
Fix timezone-independent date display
This commit is contained in:
@@ -11,6 +11,7 @@ import { toast } from 'sonner';
|
||||
import { getErrorMessage } from '@/lib/errorHandler';
|
||||
import { UserRideCredit } from '@/types/database';
|
||||
import { convertValueFromMetric, getDisplayUnit } from '@/lib/units';
|
||||
import { parseDateForDisplay } from '@/lib/dateUtils';
|
||||
import {
|
||||
AlertDialog,
|
||||
AlertDialogAction,
|
||||
@@ -233,13 +234,14 @@ export function RideCreditCard({ credit, position, maxPosition, viewMode, isEdit
|
||||
{credit.first_ride_date && (
|
||||
<div className="flex items-center gap-1">
|
||||
<Calendar className="w-3 h-3" />
|
||||
<span>First: {format(new Date(credit.first_ride_date), 'MMM d, yyyy')}</span>
|
||||
{/* ⚠️ Use parseDateForDisplay to prevent timezone shifts */}
|
||||
<span>First: {format(parseDateForDisplay(credit.first_ride_date), 'MMM d, yyyy')}</span>
|
||||
</div>
|
||||
)}
|
||||
{credit.last_ride_date && (
|
||||
<div className="flex items-center gap-1">
|
||||
<Calendar className="w-3 h-3" />
|
||||
<span>Last: {format(new Date(credit.last_ride_date), 'MMM d, yyyy')}</span>
|
||||
<span>Last: {format(parseDateForDisplay(credit.last_ride_date), 'MMM d, yyyy')}</span>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
@@ -410,7 +412,7 @@ export function RideCreditCard({ credit, position, maxPosition, viewMode, isEdit
|
||||
{credit.first_ride_date && (
|
||||
<div className="text-xs text-muted-foreground">
|
||||
<Calendar className="w-3 h-3 inline mr-1" />
|
||||
{format(new Date(credit.first_ride_date), 'MMM d, yyyy')}
|
||||
{format(parseDateForDisplay(credit.first_ride_date), 'MMM d, yyyy')}
|
||||
</div>
|
||||
)}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user