fix: strftime() sets epoch index for %G and %s format codes#127
Merged
atoomic merged 1 commit intoApr 29, 2026
Merged
Conversation
strftime() never assigned $me->[9] (the epoch timestamp), so format codes that read it — %G (GPS week) and %s (epoch seconds) — produced wrong results. %G returned -522 instead of the correct GPS week number because the uninitialized value was treated as zero. Set $me->[9] in both the timezone and non-timezone code paths, matching what time2str() already does. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.
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.
What
strftime()never set$me->[9](the epoch timestamp), causing%G(GPS week) and%s(epoch seconds) to produce wrong results.Why
format_Greads$_[0]->[9]to compute GPS weeks. Sincestrftime()never populated that index, the value wasundef(treated as 0), yielding-522instead of the correct GPS week.time2str()already sets this correctly —strftime()was just missing the same assignment.How
Added
$me->[9] = $epochin both the timezone and non-timezone code paths ofstrftime(), mirroring whattime2str()does at line 93.Testing
New
t/strftime-epoch.tverifies%Gand%sproduce correct results viastrftime(), cross-checked againsttime2str()at GPS epoch boundaries and known reference dates. Full test suite passes.🤖 Generated with Claude Code