// api/_helpers.prg — Shared helper functions for labdb PRG files // Copyright (c) 2026 Charles KWON OhJun // Safe hash get (returns "" for missing key, supports nested string paths) FUNCTION fn_HGet(hHash, cKey, xDefault) IF xDefault == NIL xDefault := "" ENDIF IF HB_ISHASH(hHash) .AND. hb_HHasKey(hHash, cKey) RETURN hHash[ cKey ] ENDIF RETURN xDefault // Format duration HH:MM:SS from start/end ISO strings FUNCTION fn_Duration(cStart, cEnd) LOCAL nSec, nH, nM, nS IF Empty(cStart) .OR. Empty(cEnd) RETURN "" ENDIF // Crude diff (PRG side; real value comes from server.js) RETURN ""