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:
parent
578b97b0c5
commit
a153f64af4
2 changed files with 14 additions and 2 deletions
|
|
@ -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' && (
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue