Skip to main content

Function: mmss_to_seconds()

mmss_to_seconds(value): number | null

Defined in: src/analytics/hockeytech.ts:150

Convert a 'MM:SS' clock string to total seconds (py mmss_to_seconds).

Parameters​

value​

unknown

The clock string (e.g. '03:16'); any non-string is stringified first. null / undefined / '' short-circuit to null.

Returns​

number | null

minutes * 60 + seconds, or null when the value is empty, has no single :, or either part is not an integer ('3', 'a:b').

Example​

import { mmss_to_seconds } from "sportsdataverse/dist/analytics/hockeytech.js";
mmss_to_seconds("03:16"); // 196
mmss_to_seconds("a:b"); // null

Remarks​

Pure and never throws; it is the clock parser behind start_s / end_s in parse_shifts.