Function: add_clock_columns()
add_clock_columns(
pbp):Row[]
Defined in: src/analytics/hockeytech.ts:419
Add minute_start, second_start, clock (remaining, "M:SS") and
sec_from_start (game seconds, +1200 per period) from time_of_period (elapsed
"M:SS") + period_of_game. Null / unparseable parts give null. A value without
a ":" throws, exactly as py's polars list.get(1) does.
Parameters
pbp
Row[]
Parsed play-by-play rows (see parse_pbp) carrying time_of_period and
period_of_game.
Returns
Row[]
A new array of copied rows with four columns appended: minute_start /
second_start (integers from the elapsed clock, null when a part is not an integer),
clock (time REMAINING in the period as 'M:SS'; '20:00' at 0:00), and
sec_from_start (elapsed game seconds: minute_start * 60 + second_start plus 1200 per
completed period for periods 2-5; no offset for an unknown period). Input order kept.
Throws
Error (get index is out of bounds) when a non-null time_of_period has no ':'.
Example
import { add_clock_columns } from "sportsdataverse/dist/analytics/hockeytech.js";
const [r] = add_clock_columns([{ time_of_period: "3:16", period_of_game: "2" }]);
r.clock; // "16:44"
r.sec_from_start; // 1396
Remarks
Copies rows (the input is untouched). Required before backfill_power_play. The remaining-clock formula assumes 20-minute periods.