Fix unit conversion logic

This commit is contained in:
gpt-engineer-app[bot]
2025-10-03 13:17:15 +00:00
parent 24aa631b62
commit b3f8c40e63
3 changed files with 60 additions and 33 deletions

View File

@@ -204,4 +204,22 @@ export function getMetricUnit(unit: string): string {
default:
return unit;
}
}
// Get display unit based on unit type and measurement system
export function getDisplayUnit(metricUnit: string, system: MeasurementSystem): string {
const unitType = detectUnitType(metricUnit);
switch (unitType) {
case 'speed':
return system === 'imperial' ? 'mph' : 'km/h';
case 'distance':
return system === 'imperial' ? 'ft' : 'm';
case 'height':
return system === 'imperial' ? 'in' : 'cm';
case 'weight':
return system === 'imperial' ? 'lbs' : 'kg';
default:
return metricUnit;
}
}