Weather/app/lib/utils.ts

15 lines
456 B
TypeScript
Raw Normal View History

2025-11-17 17:19:46 +08:00
import { clsx, type ClassValue } from "clsx"
import { twMerge } from "tailwind-merge"
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs))
}
2025-11-17 18:57:40 +08:00
export const formatTemperature = (
temp: number,
unit: 'celsius' | 'fahrenheit' = 'celsius'
): string => {
const value = unit === 'fahrenheit' ? (temp * 9) / 5 + 32 : temp;
const symbol = unit === 'fahrenheit' ? '°F' : '°C';
return `${Math.round(value)}${symbol}`;
};