datetime.parse
Parse date/time strings into standardized timestamps with IANA timezone support for temporal calculations and data processing.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| value | Yes | A date/time string parseable by JS Date | |
| tz | No | IANA timezone, e.g. Australia/Perth |
Implementation Reference
- src/server.ts:108-122 (handler)Tool registration and handler implementation for datetime.parse.
server.tool( "datetime.parse", { value: z.string().describe("A date/time string parseable by JS Date"), tz: z.string().optional().describe("IANA timezone, e.g. Australia/Perth"), }, async ({ value, tz }) => { const zone = tz || DEFAULT_TZ; const payload = parsePayload(value, zone); return { content: [{ type: "text", text: JSON.stringify(payload, null, 2) }], }; } ); - src/server.ts:55-69 (helper)The logic function parsePayload used by the datetime.parse tool.
function parsePayload(value: string, tz: string) { const d = new Date(value); if (Number.isNaN(d.getTime())) { throw new Error( `Unable to parse date value: ${formatInputForError(value)}` ); } return { input: value, tz, utcIso: d.toISOString(), epochMs: d.getTime(), human: formatHuman(d, tz), }; }