Spaces:
Running
Running
File size: 1,138 Bytes
cd61bf7 08ac9eb cd61bf7 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | import { type ClassValue, clsx } from "clsx"
import { twMerge } from "tailwind-merge"
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs))
}
export function formatDate(date: string | Date): string {
// Backend sends UTC times without 'Z' suffix, so JavaScript parses as local time
// We need to explicitly treat them as UTC
let dateStr = typeof date === 'string' ? date : date.toISOString()
// If no timezone info, assume UTC
if (!dateStr.endsWith('Z') && !dateStr.includes('+') && !dateStr.includes('-', 10)) {
dateStr = dateStr + 'Z'
}
const d = new Date(dateStr)
return d.toLocaleDateString('ru-RU', {
day: '2-digit',
month: '2-digit',
year: 'numeric',
hour: '2-digit',
minute: '2-digit'
})
}
export function getHeatColor(score: number): string {
if (score >= 70) return 'bg-red-500'
if (score >= 50) return 'bg-orange-500'
if (score >= 30) return 'bg-yellow-500'
return 'bg-gray-400'
}
export function getHeatLabel(score: number): string {
if (score >= 70) return 'HOT'
if (score >= 50) return 'WARM'
if (score >= 30) return 'COLD'
return 'JUNK'
}
|