Skip to content

fix(time): reject nonexistent local times - #4719

Open
Excelius-Wang wants to merge 1 commit into
modelcontextprotocol:mainfrom
Excelius-Wang:fix/time-reject-nonexistent-local-time
Open

fix(time): reject nonexistent local times#4719
Excelius-Wang wants to merge 1 commit into
modelcontextprotocol:mainfrom
Excelius-Wang:fix/time-reject-nonexistent-local-time

Conversation

@Excelius-Wang

Copy link
Copy Markdown

Description

Reject nonexistent local wall times during UTC offset transitions instead of silently converting them with the pre-transition offset.

Server Details

  • Server: time
  • Changes to: convert_time tool

Motivation and Context

Python allows datetime values to be constructed inside a forward clock-change gap even though those wall times never occurred. For example, 2026-03-08 02:30 in America/New_York was previously accepted and converted to 07:30 UTC.

The conversion now round-trips the source time through UTC and rejects it when the local wall time changes. Valid times immediately before and after the gap keep their existing behavior.

How Has This Been Tested?

  • uv run --python 3.12 pytest -q — 41 passed
  • uv run --python 3.12 ruff check .
  • uv run --python 3.12 pyright — 0 errors, 0 warnings
  • Covered a nonexistent New York time and valid times on both sides of the transition

This is a conversion validation change and was not tested through an LLM client.

Breaking Changes

None. Inputs that do not represent a real local time now return an error instead of a misleading conversion.

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

  • My changes follow MCP security best practices
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • No README, environment variable, or client configuration changes are required

Additional context

This uses only the standard library and the server's existing ZoneInfo conversion path. Python documents these skipped wall times as missing times in PEP 495.

Copilot AI balanced review requested due to automatic review settings August 30, 2026 09:38

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants