From 374f5b7672e3dd2409cbf6762de9c6b5ea501d0f Mon Sep 17 00:00:00 2001 From: qiuchenfan <2035024011@qq.com> Date: Mon, 17 Nov 2025 18:57:40 +0800 Subject: [PATCH] qiu4 --- app/lib/utils.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app/lib/utils.ts b/app/lib/utils.ts index bd0c391..96a51f4 100644 --- a/app/lib/utils.ts +++ b/app/lib/utils.ts @@ -4,3 +4,12 @@ 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}`; +}; \ No newline at end of file