// Smart App City — Formatters utility export const formatters = { temperature: (value: number, unit: string = '°C') => `${value.toFixed(1)}${unit}`, humidity: (value: number) => `${value}%`, aqi: (value: number) => { if (value <= 50) return { label: 'Bon', color: '#2E7D32' }; if (value <= 100) return { label: 'Modéré', color: '#F57C00' }; if (value <= 150) return { label: 'Mauvais', color: '#D32F2F' }; return { label: 'Dangereux', color: '#7B1FA2' }; }, noise: (value: number) => { if (value <= 40) return { label: 'Silencieux', color: '#2E7D32' }; if (value <= 55) return { label: 'Normal', color: '#0288D1' }; if (value <= 70) return { label: 'Bruyant', color: '#F57C00' }; return { label: 'Très bruyant', color: '#D32F2F' }; }, date: (date: string | Date, locale: string = 'fr-FR') => { const d = new Date(date); return d.toLocaleDateString(locale, { day: '2-digit', month: '2-digit', year: 'numeric', hour: '2-digit', minute: '2-digit', }); }, time: (date: string | Date) => { const d = new Date(date); return d.toLocaleTimeString('fr-FR', { hour: '2-digit', minute: '2-digit' }); }, relativeTime: (date: string | Date) => { const d = new Date(date); const now = new Date(); const diffMs = now.getTime() - d.getTime(); const diffMins = Math.floor(diffMs / 60000); const diffHours = Math.floor(diffMs / 3600000); const diffDays = Math.floor(diffMs / 86400000); if (diffMins < 1) return "À l'instant"; if (diffMins < 60) return `Il y a ${diffMins} min`; if (diffHours < 24) return `Il y a ${diffHours}h`; if (diffDays < 7) return `Il y a ${diffDays}j`; return d.toLocaleDateString('fr-FR', { day: '2-digit', month: '2-digit' }); }, currency: (value: number, currency: string = 'EUR') => new Intl.NumberFormat('fr-FR', { style: 'currency', currency }).format(value), };