Skip to content

fix(api): correct UTC offset label for negative half-hour timezones - #10079

Open
Abhishek-B-R wants to merge 1 commit into
makeplane:previewfrom
Abhishek-B-R:fix/timezone-negative-half-hour-offset
Open

Abhishek-B-R wants to merge 1 commit into
makeplane:previewfrom
Abhishek-B-R:fix/timezone-negative-half-hour-offset

Conversation

@Abhishek-B-R

@Abhishek-B-R Abhishek-B-R commented Oct 18, 2026 •

Copy link
Copy Markdown

Description

The timezone picker gets its "UTC-xx:xx" labels from GET /api/timezones/, and every zone that is west of UTC with a half-hour offset comes back one hour too far west.

The label is built like this:

hours_offset = total_seconds // 3600
minutes_offset = abs(total_seconds % 3600) // 60

Python floors negative division, so for Marquesas (-34200 seconds) hours_offset is -10 and the minutes come out as 30, giving UTC-10:30. The real offset is UTC-09:30. Positive zones like Kolkata (+05:30) and Kathmandu (+05:45) are fine, which is probably why nobody noticed.

What the endpoint returns today vs what it should:

Zone Returned Actual
Pacific/Marquesas UTC-10:30 UTC-09:30
America/St_Johns (winter) UTC-04:30 UTC-03:30
America/St_Johns (summer, i.e. right now) UTC-03:30 UTC-02:30

So anyone in Newfoundland picking their timezone sees a label an hour off, and searching the picker for "GMT-02:30" finds nothing.

The fix takes the sign first and splits the absolute value with divmod, so the hours and minutes are always computed on a positive number. The strftime("%z") value used for sorting is untouched.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)

Test Scenarios

Added apps/api/plane/tests/unit/views/test_timezone_endpoint.py. It calls the endpoint with datetime.now() pinned to a January and a July date (so the Newfoundland DST case is covered) and a locmem cache, and checks both utc_offset and gmt_offset for Marquesas, St Johns, Kolkata, Kathmandu, Los Angeles and Reykjavik.

Before the fix, 3 of the 7 cases fail (the three rows in the table above). After the fix all 7 pass. ruff check and ruff format --check are clean on both files.

References

No existing issue. Found by reading the offset formatting while checking how half-hour zones (I'm in IST) are handled.

Summary by CodeRabbit

  • Bug Fixes
    • Timezone labels now display the correct UTC/GMT sign and offset for fractional-hour differences, including negative half-hour offsets in winter and summer.
    • Labels for whole-hour offsets and UTC continue to display correctly.

The hours were taken with floor division on a negative number of seconds,
so -34200 // 3600 gave -10 and Marquesas showed as UTC-10:30 instead of
UTC-09:30. Newfoundland was off by an hour the same way. Take the sign
first and split the absolute value instead.
Copilot AI balanced review requested due to automatic review settings October 18, 2026 06:59

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.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@coderabbitai

coderabbitai Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 79372141-3ec7-4123-8c1c-c4073fd7e520
📥 Commits

Reviewing files that changed from the base of the PR and between 879ce8b and 1a15b9f.

📒 Files selected for processing: 2
  • apps/api/plane/app/views/timezone/base.py
  • apps/api/plane/tests/unit/views/test_timezone_endpoint.py

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

📝 Walkthrough

The timezone endpoint now derives offset signs from the total offset and calculates hours and minutes from its absolute value. New parameterized tests check UTC and GMT labels for listed timezones and dates.

Changes: Timezone offset formatting

Layer / File(s) Summary
Offset formatting and endpoint tests
apps/api/plane/app/views/timezone/base.py, apps/api/plane/tests/unit/views/test_timezone_endpoint.py
The endpoint formats offset signs using the total offset and calculates hours and minutes from its absolute value. Parameterized tests check UTC and GMT labels across timezones and dates.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 1a15b

This fixes the offset labels for western half-hour timezones such as Pacific/Marquesas and America/St_Johns. No merge-blocking risk was identified.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly identifies the API bug and the affected negative half-hour UTC offset labels.
Description check Passed The description includes the change details, selected bug-fix type, test scenarios, and references. The screenshots section is not included, but screenshots are not applicable to this API-only change.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

This branch has not been deployed

No deployments
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.

3 participants