refactor: replace parseFloat with parseAppDecimal and formatAppDecimal for improved number handling

Updated various components to utilize parseAppDecimal and formatAppDecimal for consistent decimal parsing and formatting. This change enhances the handling of numeric inputs across the application, ensuring better accuracy and user experience in forms and displays.
This commit is contained in:
2026-06-03 18:07:22 +02:00
parent 79762a0baf
commit 3cab735754
19 changed files with 340 additions and 128 deletions
+5 -1
View File
@@ -1,3 +1,5 @@
import { formatAppDecimal } from './numberFormat.js'
/** Barometric pressure (hPa), typical marine range. */
export const PRESSURE_MIN_HPA = 960
export const PRESSURE_MAX_HPA = 1050
@@ -90,7 +92,9 @@ export function formatVisibilityMeters(meters: number): string {
if (meters >= 1000) {
const km = meters / 1000
const rounded = Math.round(km * 10) / 10
return Number.isInteger(rounded) ? `${rounded} km` : `${rounded.toFixed(1)} km`
return Number.isInteger(rounded)
? `${formatAppDecimal(rounded, { maximumFractionDigits: 0 })} km`
: `${formatAppDecimal(rounded, { minimumFractionDigits: 1, maximumFractionDigits: 1 })} km`
}
return `${Math.round(meters)} m`
}