fix(rate-limits): parse resets_at with GNU date so time-remaining shows on Linux/Windows#38
Open
marciogranzotto wants to merge 1 commit into
Open
Conversation
…ws on Linux/Windows The reset timestamps were parsed only with BSD `date -j -f` (macOS). On GNU date (Linux, Git Bash on Windows) that fails silently, the epoch falls back to 0, remaining time goes negative, and the "(2h 15m)" / "(3d 4h)" display never appears even with RATE_SHOW_TIME_REMAINING=true. Try BSD first, then GNU `date -d`, keeping 0 as the final fallback. Co-Authored-By: Claude Fable 5 <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
RATE_SHOW_TIME_REMAINING(default:true) never displays anything on Linux or Windows (Git Bash). Theresets_attimestamps are parsed only with BSD date syntax:GNU date doesn't support
-j/-f, so this silently falls back to epoch0, the computed remaining time goes negative, and the(2h 15m)/(3d 4h)suffix is skipped — with no error, since stderr is discarded. macOS users are unaffected.Fix
Adds a small
_parse_reset_epochhelper that tries BSDdate -j -ffirst (macOS), then GNUdate -d(Linux, Git Bash), keeping0as the final fallback. Both call sites (5-hour and 7-day) now use it. No behavior change on macOS.Testing
5h:24% 🟢 7d:71% 🟡; after,5h:24% 🟢 (2h 4m) 7d:71% 🟡 (3d 21h).-jis unsupported.bash tests/test_utils.shandbash tests/test_sandbox.shpass (27/27).🤖 Generated with Claude Code