Skip to content

fix: strftime() sets epoch index for %G and %s format codes#127

Merged
atoomic merged 1 commit into
cpan-authors:mainfrom
Koan-Bot:koan.atoomic/fix-strftime-epoch-index
Apr 29, 2026
Merged

fix: strftime() sets epoch index for %G and %s format codes#127
atoomic merged 1 commit into
cpan-authors:mainfrom
Koan-Bot:koan.atoomic/fix-strftime-epoch-index

Conversation

@Koan-Bot
Copy link
Copy Markdown

What

strftime() never set $me->[9] (the epoch timestamp), causing %G (GPS week) and %s (epoch seconds) to produce wrong results.

Why

format_G reads $_[0]->[9] to compute GPS weeks. Since strftime() never populated that index, the value was undef (treated as 0), yielding -522 instead of the correct GPS week. time2str() already sets this correctly — strftime() was just missing the same assignment.

How

Added $me->[9] = $epoch in both the timezone and non-timezone code paths of strftime(), mirroring what time2str() does at line 93.

Testing

New t/strftime-epoch.t verifies %G and %s produce correct results via strftime(), cross-checked against time2str() at GPS epoch boundaries and known reference dates. Full test suite passes.


🤖 Generated with Claude Code

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>
@atoomic atoomic marked this pull request as ready for review April 29, 2026 09:36
Copy link
Copy Markdown

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

@atoomic atoomic merged commit 5c0c2cf into cpan-authors:main Apr 29, 2026
22 checks passed
@Koan-Bot Koan-Bot deleted the koan.atoomic/fix-strftime-epoch-index branch April 29, 2026 10:21
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