Skip to main content

Function: parseUptimeValue()

parseUptimeValue(uptimeString: string): number

Defined in: src/utils/monitoring/dataValidation.ts:55

Parse and validate uptime string to number. Handles strings with percent signs and validates the result.

Parametersโ€‹

uptimeStringโ€‹

string

The uptime string to parse (may contain % signs).

Returnsโ€‹

number

Validated uptime number between 0 and 100, or 0 if invalid.

Remarksโ€‹

Removes whitespace and percent symbols, converts the remaining value to a floating point number, and clamps the result to the 0โ€“100 range. Invalid inputs are logged for diagnostics and return the fallback value 0.