time-and-zone-info
Retrieve current time, timezone, and UTC offset for any geographic coordinates. Provides IANA TZID, active offsets, and RFC 2822 timestamp.
Instructions
Get the current time and zone info at any point (geographic coordinates). Output includes includes the standard UTC offset, special offset currently in effect (typically but not always Daylight Saving Time), IANA TZID, and the current timestamp in RFC 28222 format.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| lat | Yes | The latitude of the point. | |
| lon | Yes | The longitude of the point. |
Implementation Reference
- src/tools/tz.ts:9-39 (handler)The handler function `timeAndZoneInfo` that performs timezone lookup using Stadia Maps GeospatialApi and returns formatted text output including TZID, offsets, and local time.export async function timeAndZoneInfo({ lat, lon, }: Coordinates): Promise<CallToolResult> { return handleToolError( async () => { const res = await miscApi.tzLookup({ lat, lng: lon, }); return { content: [ { type: "text", text: [ `TZID: ${res.tzId}`, `Standard UTC offset: ${res.baseUtcOffset}`, `Special offset (e.g. DST): ${res.dstOffset}`, `Current time (RFC 2822): ${res.localRfc2822Timestamp}`, ].join("\n"), }, ], }; }, { contextMessage: "Timezone lookup failed", enableLogging: true, }, ); }
- src/schemas.ts:10-20 (schema)Zod input schemas for latitude and longitude parameters used in the tool's input validation.export const latitudeSchema = z .number() .min(-90) .max(90) .describe("The latitude of the point."); export const longitudeSchema = z .number() .min(-180) .max(180) .describe("The longitude of the point.");
- src/types.ts:8-11 (schema)TypeScript type definition for Coordinates used as parameter type in the handler function.export type Coordinates = { lat: number; lon: number; };
- src/index.ts:37-45 (registration)Registration of the "time-and-zone-info" tool using McpServer.tool, specifying name, description, input schema, and handler reference.server.tool( "time-and-zone-info", "Get the current time and zone info at any point (geographic coordinates). Output includes includes the standard UTC offset, special offset currently in effect (typically but not always Daylight Saving Time), IANA TZID, and the current timestamp in RFC 28222 format.", { lat: latitudeSchema, lon: longitudeSchema, }, timeAndZoneInfo, );