fix: resolve local timezone to IANA name for sleep commands#21
fix: resolve local timezone to IANA name for sleep commands#21dtrinh 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>
|
Hey @dtrinh — nice fix! The This looks good to merge. A couple of minor notes:
If you can rebase, I'll get this merged. Thanks for the contribution! |
|
Update: PR #31 just landed with a Your approach with Either way, thanks for identifying this! |
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