Skip to content

Commit 2c5826a

Browse files
committed
better timezone calculations
1 parent c792af4 commit 2c5826a

5 files changed

Lines changed: 267 additions & 171 deletions

File tree

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "chuk-mcp-time"
3-
version = "1.0.1"
3+
version = "1.0.2"
44
description = "High-accuracy time oracle MCP server using NTP consensus and multiple time sources"
55
readme = "README.md"
66
requires-python = ">=3.11"

src/chuk_mcp_time/server.py

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -258,9 +258,9 @@ async def get_local_time(
258258
return LocalTimeResponse(
259259
local_datetime=local_dt.isoformat(),
260260
timezone=timezone,
261-
utc_offset_seconds=tz_info["utc_offset_seconds"], # type: ignore[arg-type]
262-
is_dst=tz_info["is_dst"], # type: ignore[arg-type]
263-
abbreviation=tz_info["abbreviation"], # type: ignore[arg-type]
261+
utc_offset_seconds=tz_info.utc_offset_seconds,
262+
is_dst=tz_info.is_dst,
263+
abbreviation=tz_info.abbreviation,
264264
source_utc=time_response.iso8601_time,
265265
tzdata_version=get_tzdata_version(),
266266
estimated_error_ms=time_response.estimated_error_ms,
@@ -289,14 +289,14 @@ async def convert_time(
289289
result = convert_datetime_between_timezones(datetime_str, from_timezone, to_timezone)
290290

291291
return TimezoneConversionResponse(
292-
from_timezone=result["from_timezone"], # type: ignore[arg-type]
293-
from_datetime=result["from_datetime"], # type: ignore[arg-type]
294-
from_utc_offset_seconds=result["from_utc_offset_seconds"], # type: ignore[arg-type]
295-
to_timezone=result["to_timezone"], # type: ignore[arg-type]
296-
to_datetime=result["to_datetime"], # type: ignore[arg-type]
297-
to_utc_offset_seconds=result["to_utc_offset_seconds"], # type: ignore[arg-type]
298-
offset_difference_seconds=result["offset_difference_seconds"], # type: ignore[arg-type]
299-
explanation=result["explanation"], # type: ignore[arg-type]
292+
from_timezone=result.from_timezone,
293+
from_datetime=result.from_datetime.isoformat(),
294+
from_utc_offset_seconds=result.from_utc_offset_seconds,
295+
to_timezone=result.to_timezone,
296+
to_datetime=result.to_datetime.isoformat(),
297+
to_utc_offset_seconds=result.to_utc_offset_seconds,
298+
offset_difference_seconds=result.offset_difference_seconds,
299+
explanation=result.explanation,
300300
)
301301

302302

@@ -321,10 +321,10 @@ async def list_timezones(
321321

322322
timezones = [
323323
TimezoneInfo(
324-
id=tz["id"], # type: ignore[arg-type]
325-
country_code=tz["country_code"],
326-
comment=tz["comment"],
327-
example_city=tz["example_city"],
324+
id=tz.id,
325+
country_code=tz.country_code,
326+
comment=tz.comment,
327+
example_city=tz.example_city,
328328
)
329329
for tz in timezones_data
330330
]
@@ -369,10 +369,10 @@ async def get_timezone_info(
369369

370370
transitions = [
371371
TimezoneTransition(
372-
from_datetime=t["from_datetime"], # type: ignore[arg-type]
373-
utc_offset_seconds=t["utc_offset_seconds"], # type: ignore[arg-type]
374-
is_dst=t["is_dst"], # type: ignore[arg-type]
375-
abbreviation=t["abbreviation"], # type: ignore[arg-type]
372+
from_datetime=t.from_datetime.isoformat(),
373+
utc_offset_seconds=t.utc_offset_seconds,
374+
is_dst=t.is_dst,
375+
abbreviation=t.abbreviation,
376376
)
377377
for t in transitions_data
378378
]
@@ -381,9 +381,9 @@ async def get_timezone_info(
381381
timezone=timezone,
382382
country_code=None, # Would need full zone1970.tab parsing
383383
comment=None,
384-
current_offset_seconds=current_info["utc_offset_seconds"], # type: ignore[arg-type]
385-
current_is_dst=current_info["is_dst"], # type: ignore[arg-type]
386-
current_abbreviation=current_info["abbreviation"], # type: ignore[arg-type]
384+
current_offset_seconds=current_info.utc_offset_seconds,
385+
current_is_dst=current_info.is_dst,
386+
current_abbreviation=current_info.abbreviation,
387387
transitions=transitions,
388388
tzdata_version=get_tzdata_version(),
389389
)

0 commit comments

Comments
 (0)