getTimezones
Retrieve all available timezones in Teamwork to use when updating a user's timezone settings.
Instructions
Get all timezones available in Teamwork. This is useful when you need to update a user's timezone and need to know the available options.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/core/getTimezones.ts:28-43 (handler)Tool handler function that calls teamworkService.getTimezones() and returns the result as JSON text content.
export async function handleGetTimezones() { logger.info('Calling teamworkService.getTimezones()'); try { const result = await teamworkService.getTimezones(); logger.info('Successfully retrieved timezones'); return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] }; } catch (error: any) { return createErrorResponse(error, 'Retrieving timezones'); } - src/tools/core/getTimezones.ts:11-25 (schema)Tool definition/schema for getTimezones. No input parameters required.
export const getTimezonesDefinition = { name: "getTimezones", description: "Get all timezones available in Teamwork. This is useful when you need to update a user's timezone and need to know the available options.", inputSchema: { type: 'object', properties: {}, required: [] }, annotations: { title: "Get Timezones", readOnlyHint: false, destructiveHint: false, openWorldHint: false } }; - src/tools/index.ts:56-101 (registration)Import and registration of getTimezones in the toolPairs array, mapping its definition to its handler.
import { getTimezonesDefinition as getTimezones, handleGetTimezones } from './core/getTimezones.js'; // Define a structure that pairs tool definitions with their handlers interface ToolPair { definition: any; handler: Function; } // Create an array of tool pairs const toolPairs: ToolPair[] = [ { definition: getProjects, handler: handleGetProjects }, { definition: getCurrentProject, handler: handleGetCurrentProject }, { definition: createProject, handler: handleCreateProject }, { definition: getTasks, handler: handleGetTasks }, { definition: getTasksByProjectId, handler: handleGetTasksByProjectId }, { definition: getTaskListsByProjectId, handler: handleGetTaskListsByProjectId }, { definition: getTasksByTaskListId, handler: handleGetTasksByTaskListId }, { definition: getTaskById, handler: handleGetTaskById }, { definition: createTask, handler: handleCreateTask }, { definition: createSubTask, handler: handleCreateSubTask }, { definition: updateTask, handler: handleUpdateTask }, { definition: deleteTask, handler: handleDeleteTask }, { definition: getTasksMetricsComplete, handler: handleGetTasksMetricsComplete }, { definition: getTasksMetricsLate, handler: handleGetTasksMetricsLate }, { definition: getTaskSubtasks, handler: handleGetTaskSubtasks }, { definition: getTaskComments, handler: handleGetTaskComments }, { definition: createComment, handler: handleCreateComment }, { definition: getPeople, handler: handleGetPeople }, { definition: getPersonById, handler: handleGetPersonById }, { definition: getProjectPeople, handler: handleGetProjectPeople }, { definition: addPeopleToProject, handler: handleAddPeopleToProject }, { definition: deletePerson, handler: handleDeletePerson }, { definition: updatePerson, handler: handleUpdatePerson }, { definition: createCompany, handler: handleCreateCompany }, { definition: updateCompany, handler: handleUpdateCompany }, { definition: deleteCompany, handler: handleDeleteCompany }, { definition: getCompanies, handler: handleGetCompanies }, { definition: getCompanyById, handler: handleGetCompanyById }, { definition: getProjectsPeopleMetricsPerformance, handler: handleGetProjectsPeopleMetricsPerformance }, { definition: getProjectsPeopleUtilization, handler: handleGetProjectsPeopleUtilization }, { definition: getAllocationTime, handler: handleGetProjectsAllocationsTime }, { definition: getTime, handler: handleGetTime }, { definition: getProjectPerson, handler: handleGetProjectPerson }, { definition: getProjectsReportingUserTaskCompletion, handler: handleGetProjectsReportingUserTaskCompletion }, { definition: getProjectsReportingUtilization, handler: handleGetProjectsReportingUtilization }, { definition: getTimezones, handler: handleGetTimezones } - src/tools/index.ts:149-149 (registration)Re-export of handleGetTimezones from the tools index.
export { handleGetTimezones } from './core/getTimezones.js'; - Service function that calls the Teamwork API endpoint 'timezones.json' (v1) and returns the response data.
export const getTimezones = async () => { try { logger.info('Fetching all timezones'); const api = getApiClientForVersion('v1'); // Note: This is a v1 API endpoint without the projects/api/v3 prefix const response = await api.get('timezones.json'); logger.info(`Successfully retrieved ${response.data.timezones?.length || 0} timezones`); return response.data; } catch (error: any) { logger.error(`Error fetching timezones: ${error.message}`); throw new Error(`Failed to fetch timezones: ${error.message}`); } };