fix: str2time maps 4-digit pre-1970 years to future (RT#84075/GH#12)#87
Merged
atoomic merged 1 commit intocpan-authors:mainfrom Mar 18, 2026
Merged
Conversation
Collaborator
|
@Koan-Bot rebase |
Author
Rebase: fix: str2time maps 4-digit pre-1970 years to future (RT#84075/GH#12)Branch Diff: 58 files changed, 2417 insertions(+), 1414 deletions(-) Review feedback was analyzed and applied. Actions
Automated by Kōan |
The fix for str2time mapping 4-digit years like 1963 to 2063 has been in place since commit d745098 (2015): strptime extracts the century from 4-digit years and str2time reconstructs the full year before calling timegm/timelocal, bypassing Time::Local's 50-year sliding window. This commit: - Adds a second assertion to the RT#84075 block that pins the exact example from the issue report (1963-12-31 → 1963, not 2063) - Updates the test label to cross-reference GH#12 Fixes cpan-authors#12 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1e7c9aa to
2fbb87b
Compare
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
str2time("1963-12-31 23:59:59 UTC")was returning a timestamp in 2063 instead of 1963. The root cause wasstrptime()reducing a 4-digit year to a 2-digit offset (1963 → 63), whichtimegm/timelocalthen mapped forward via the 50-year sliding window.The fix has been present since d745098 (2015):
strptime()now extracts the century separately andstr2time()reconstructs the full 4-digit year before callingtimegm/timelocal, bypassing the windowing entirely.Fixes #12
Changes
1963-12-31must not map to2063)Test plan
prove -l t/cpanrt.t→ 26/26 tests passprove -l t/→ 977/977 tests passGenerated by Kōan /fix
Quality Report
Changes: 1 file changed, 12 insertions(+), 3 deletions(-)
Code scan: clean
Tests: skipped
Branch hygiene: clean
Generated by Kōan post-mission quality pipeline