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

Method fromString

packages/graph/src/TemporalTypes.ts:60–67  ·  view source on GitHub ↗

* Create a DateValue from an ISO date string (YYYY-MM-DD).

(iso: string)

Source from the content-addressed store, hash-verified

58 * Create a DateValue from an ISO date string (YYYY-MM-DD).
59 */
60 public static fromString(iso: string): DateValue | null {
61 const match = iso.match(/^(\d{4})-(\d{2})-(\d{2})$/);
62 if (!match || !match[1] || !match[2] || !match[3]) return null;
63 const year = parseInt(match[1], 10);
64 const month = parseInt(match[2], 10);
65 const day = parseInt(match[3], 10);
66 return new DateValue(year, month, day);
67 }
68
69 /**
70 * Create a DateValue from a map of components.

Calls

no outgoing calls

Tested by

no test coverage detected