Format available_from dates as human-readable on listing cards

Display dates like "22 Jun 2025" instead of raw ISO timestamps.
This commit is contained in:
Viktor Barzin 2026-02-21 18:02:14 +00:00
parent 578b97b0c5
commit a153f64af4
No known key found for this signature in database
GPG key ID: 0EB088298288D958
2 changed files with 14 additions and 2 deletions

View file

@ -2,6 +2,12 @@ import { ExternalLink, Bed, Maximize2, PoundSterling, Clock, Building, Footprint
import { Button } from './ui/button';
import type { PropertyProperties, POIDistanceInfo, POI } from '@/types';
function formatDate(value: string): string {
const date = new Date(value);
if (isNaN(date.getTime())) return value;
return date.toLocaleDateString('en-GB', { day: 'numeric', month: 'short', year: 'numeric' });
}
function formatDuration(seconds: number): string {
const minutes = Math.round(seconds / 60);
if (minutes < 60) return `${minutes}m`;
@ -231,7 +237,7 @@ export function PropertyCard({
{property.listing_type !== 'BUY' && property.available_from && (
<div className="flex items-center gap-2 text-sm">
<Clock className="h-4 w-4 text-muted-foreground" />
<span>Available <strong>{property.available_from}</strong></span>
<span>Available <strong>{formatDate(property.available_from)}</strong></span>
</div>
)}
{property.listing_type === 'BUY' && (