list-timezones
Retrieve a comprehensive list of all available timezones for accurate datetime handling and scheduling across global regions.
Instructions
List all available timezones
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/server.ts:73-84 (handler)The handler function for the 'list-timezones' tool, registered inline with server.tool(). It returns a text content with the formatted list of available timezones obtained from getFormattedTimezoneList().server.tool( "list-timezones", "List all available timezones", async () => { return { content: [{ type: "text", text: getFormattedTimezoneList() }] }; } );
- src/server.ts:73-84 (registration)Registration of the 'list-timezones' tool using server.tool(), including its description and handler.server.tool( "list-timezones", "List all available timezones", async () => { return { content: [{ type: "text", text: getFormattedTimezoneList() }] }; } );
- src/timezone-utils.ts:42-45 (helper)Helper function that formats the list of available timezones into a readable string, used by the list-timezones tool handler.export function getFormattedTimezoneList(prefix: string = "Available timezones"): string { const timezones = getAvailableTimezones(); return `${prefix} (${timezones.length}): ${timezones.join(', ')}`; }
- src/timezone-utils.ts:22-35 (helper)Core helper that retrieves all available timezones using Intl.supportedValuesOf('timeZone'), adds common ones, sorts them, with fallback to COMMON_TIMEZONES.export function getAvailableTimezones(): string[] { try { const timezones = new Set<string>(Intl.supportedValuesOf('timeZone')); // Ensure common timezones are always included COMMON_TIMEZONES.forEach(tz => timezones.add(tz)); return Array.from(timezones).sort(); } catch (error) { console.error("Error getting timezones from Intl API:", error); // Fallback to common timezones if the Intl API fails return COMMON_TIMEZONES; } }
- src/timezone-utils.ts:2-16 (helper)Array of common timezones ensured to be available as fallback and for resource listing.export const COMMON_TIMEZONES = [ "UTC", "Europe/London", "Europe/Paris", "Europe/Berlin", "America/New_York", "America/Chicago", "America/Denver", "America/Los_Angeles", "Asia/Tokyo", "Asia/Shanghai", "Asia/Kolkata", "Australia/Sydney", "Pacific/Auckland" ];