Skip to content

Conversation

@ababino
Copy link

@ababino ababino commented Apr 5, 2025

Description

If system timezone is not in the IANA standard, these changes will set the timezone based on the UTC offset.
This fixes #489, #612, and #786.
The solution is better than PR #925 because it will not fail even if datetime.now() tzone is not IANA.
The solution is also better than PR #320 because it does not relies on hardcoded mappings.

Server Details

  • Server: Time
  • Changes to: tools

Motivation and Context

It doesn't work with my local setup unless the --local-timezone flag is specified.

How Has This Been Tested?

With Claude Desktop

Breaking Changes

No

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Protocol Documentation
  • My changes follows MCP security best practices
  • I have updated the server's README accordingly
  • I have tested this with an LLM client
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have documented all environment variables and configuration options

Additional context

@olaservo olaservo added server-time Reference implementation for the Time MCP server - src/time bug Something isn't working labels Apr 18, 2025
@olaservo
Copy link
Member

Thanks for the PR! I wonder if we should incorporate the tzlocal approach from 925 as the primary approach and then do fallbacks in this order:

First attempt to use tzlocal (from PR #925) to cover platform-specific names

First fallback: Try direct ZoneInfo conversion, for cases where a valid IANA name is provided

Final fallback: Then use UTC offset matching like you have in this PR, to handle the remaining scenarios

What do you think?

@domdomegg
Copy link
Member

domdomegg commented Aug 1, 2025

Superceded by #1761

@domdomegg domdomegg closed this Aug 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working server-time Reference implementation for the Time MCP server - src/time

Projects

None yet

Development

Successfully merging this pull request may close these issues.

time server not working

3 participants