Skip to content

Fix llm_time timezone_offset format for negative UTC offsets - #1529

Open
ikatyal2110 wants to merge 1 commit into
simonw:mainfrom
ikatyal2110:fix-llm-time-negative-timezone-offset
Open

Fix llm_time timezone_offset format for negative UTC offsets#1529
ikatyal2110 wants to merge 1 commit into
simonw:mainfrom
ikatyal2110:fix-llm-time-negative-timezone-offset

Conversation

@ikatyal2110

Copy link
Copy Markdown
Contributor

The timezone_offset field in llm_time() produced malformed strings for west-of-UTC zones: "UTC-5:00" instead of "UTC-05:00" because Python's :02d format specifier only zero-pads positive numbers. Additionally, floor division on negative offset_seconds yielded the wrong hour for sub-hour offsets (e.g. UTC-3:30 became UTC-4:50 instead of UTC-3:30). The fix computes hours and minutes from abs(offset_seconds) and tracks the sign separately, producing correctly zero-padded offsets like "UTC-05:00" and "UTC+05:30".


Generated by Claude Code

Two bugs in the original computation: floor division on negative
offset_seconds gave wrong hours for sub-hour offsets (e.g. UTC-3:30
became UTC-4:50), and the :02d format specifier does not zero-pad
negative numbers (so UTC-5 produced "UTC-5:00" instead of "UTC-05:00").

Fix by working with abs(offset_seconds) for the hour/minute split and
tracking the sign separately, then formatting with f"UTC{sign}{h:02d}:{m:02d}".
Adds a test that mocks time module globals to verify UTC-05:00 and UTC+05:30.
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