Weather/app/lib/utils.ts

15 lines
456 B
TypeScript

import { clsx, type ClassValue } from "clsx"
import { twMerge } from "tailwind-merge"
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs))
}
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}`;
};