MCPcopy Create free account
hub / github.com/codemix/graph / fromString

Method fromString

packages/graph/src/TemporalTypes.ts:212–230  ·  view source on GitHub ↗

* Create a LocalTimeValue from an ISO time string (HH:MM:SS.nnnnnnnnn).

(iso: string)

Source from the content-addressed store, hash-verified

210 * Create a LocalTimeValue from an ISO time string (HH:MM:SS.nnnnnnnnn).
211 */
212 public static fromString(iso: string): LocalTimeValue | null {
213 // Match time format: HH:MM:SS or HH:MM:SS.fractional
214 const match = iso.match(/^(\d{2}):(\d{2}):(\d{2})(?:\.(\d{1,9}))?$/);
215 if (!match || !match[1] || !match[2] || !match[3]) return null;
216
217 const hour = parseInt(match[1], 10);
218 const minute = parseInt(match[2], 10);
219 const second = parseInt(match[3], 10);
220
221 // Parse fractional seconds as nanoseconds
222 let nanosecond = 0;
223 if (match[4]) {
224 // Pad to 9 digits
225 const frac = match[4].padEnd(9, "0");
226 nanosecond = parseInt(frac, 10);
227 }
228
229 return new LocalTimeValue(hour, minute, second, nanosecond);
230 }
231
232 /**
233 * Create a LocalTimeValue from a map of components.

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected