fix: correct sub-hour timezone drift in getETDate#462
Merged
jonwiggins merged 1 commit intojonwiggins:mainfrom Apr 20, 2026
Merged
fix: correct sub-hour timezone drift in getETDate#462jonwiggins merged 1 commit intojonwiggins:mainfrom
jonwiggins merged 1 commit intojonwiggins:mainfrom
Conversation
The two-pass drift correction used setHours() (local time) and only accounted for whole-hour drift. On systems with sub-hour UTC offsets (e.g. IST = UTC+5:30) this introduced a 30-minute error, causing off-peak transition times to be calculated incorrectly. Fix: use setTime() with a millisecond-precision drift that includes the minute component from getETComponents. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This was referenced Apr 20, 2026
jplorier
pushed a commit
to jplorier/optio
that referenced
this pull request
May 5, 2026
The two-pass drift correction used setHours() (local time) and only accounted for whole-hour drift. On systems with sub-hour UTC offsets (e.g. IST = UTC+5:30) this introduced a 30-minute error, causing off-peak transition times to be calculated incorrectly. Fix: use setTime() with a millisecond-precision drift that includes the minute component from getETComponents. Co-authored-by: Ramesh Nethi <r.nethi@gogatewayai.com> Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
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.
Summary
Fixes off-peak time calculation errors on systems with sub-hour UTC offsets (e.g., IST = UTC+5:30). The existing drift correction used
setHours()which only accounted for whole-hour offsets, introducing a 30-minute error for sub-hour timezones.Changes
packages/shared/src/utils/off-peak.ts: ReplacesetHours()drift correction withsetTime()using millisecond-precision calculationgetETComponentsin drift calculation to handle sub-hour timezone offsetsTesting
pnpm turbo test)pnpm turbo typecheck)Tested on IST (UTC+5:30) system where off-peak transition times were previously off by 30 minutes.
Related
Discovered during local development on system with sub-hour UTC offset.