fix: resolve local timezone to IANA name for sleep commands#21
Open
dtrinh wants to merge 1 commit intosteipete:mainfrom
Open
fix: resolve local timezone to IANA name for sleep commands#21dtrinh wants to merge 1 commit intosteipete:mainfrom
dtrinh wants to merge 1 commit intosteipete:mainfrom
Conversation
time.Local.String() returns "Local" on macOS/Linux, which is not a valid IANA timezone name and gets rejected by the Eight Sleep API with a 400 BadRequest error listing all valid timezone values. Add resolveTimezone() which detects the system IANA timezone by reading /etc/localtime symlink (macOS/Linux) or TZ env var. Fixes sleep day and sleep range commands when using the default --timezone=local setting. Co-Authored-By: Claude Opus 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
sleep dayandsleep rangefail with400 BadRequestwhen using the default--timezone=localbecausetime.Local.String()returns"Local", which is not a valid IANA timezone nameresolveTimezone()helper that detects the system IANA timezone by reading the/etc/localtimesymlink (macOS/Linux) orTZenv varsleep dayandsleep rangecommandsRoot Cause
The existing code did:
The Eight Sleep API rejects
"Local"as an invalid timezone value.Test plan
eightctl sleep day --quietworks without specifying--timezoneeightctl sleep range --from 2026-02-14 --to 2026-02-21 --quietworks without specifying--timezone--timezone America/New_Yorkstill worksgo build ./cmd/eightctlcompiles cleanly🤖 Generated with Claude Code