Fix llm_time timezone_offset format for negative UTC offsets - #1529
Open
ikatyal2110 wants to merge 1 commit into
Open
Fix llm_time timezone_offset format for negative UTC offsets#1529ikatyal2110 wants to merge 1 commit into
ikatyal2110 wants to merge 1 commit into
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
timezone_offsetfield inllm_time()produced malformed strings for west-of-UTC zones:"UTC-5:00"instead of"UTC-05:00"because Python's:02dformat specifier only zero-pads positive numbers. Additionally, floor division on negativeoffset_secondsyielded 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 fromabs(offset_seconds)and tracks the sign separately, producing correctly zero-padded offsets like"UTC-05:00"and"UTC+05:30".Generated by Claude Code