Skip to content

fix: correct sub-hour timezone drift in getETDate#462

Merged
jonwiggins merged 1 commit intojonwiggins:mainfrom
nethi:feat/public-fix-timezone-drift
Apr 20, 2026
Merged

fix: correct sub-hour timezone drift in getETDate#462
jonwiggins merged 1 commit intojonwiggins:mainfrom
nethi:feat/public-fix-timezone-drift

Conversation

@nethi
Copy link
Copy Markdown
Contributor

@nethi nethi commented Apr 20, 2026

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: Replace setHours() drift correction with setTime() using millisecond-precision calculation
  • Include minute component from getETComponents in drift calculation to handle sub-hour timezone offsets

Testing

  • Tests pass (pnpm turbo test)
  • Typechecks pass (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.

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>
@jonwiggins jonwiggins merged commit 8d2e082 into jonwiggins:main Apr 20, 2026
7 checks passed
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>
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