Skip to content

fix: str2time maps 4-digit pre-1970 years to future (RT#84075/GH#12)#87

Merged
atoomic merged 1 commit intocpan-authors:mainfrom
Koan-Bot:koan.atoomic/fix-issue-12
Mar 18, 2026
Merged

fix: str2time maps 4-digit pre-1970 years to future (RT#84075/GH#12)#87
atoomic merged 1 commit intocpan-authors:mainfrom
Koan-Bot:koan.atoomic/fix-issue-12

Conversation

@Koan-Bot
Copy link
Copy Markdown

@Koan-Bot Koan-Bot commented Mar 15, 2026

Summary

str2time("1963-12-31 23:59:59 UTC") was returning a timestamp in 2063 instead of 1963. The root cause was strptime() reducing a 4-digit year to a 2-digit offset (1963 → 63), which timegm/timelocal then mapped forward via the 50-year sliding window.

The fix has been present since d745098 (2015): strptime() now extracts the century separately and str2time() reconstructs the full 4-digit year before calling timegm/timelocal, bypassing the windowing entirely.

Fixes #12

Changes

  • Updated the RT#84075 regression test block to also reference GH#12
  • Added an explicit assertion for the canonical example from the issue (1963-12-31 must not map to 2063)

Test plan

  • prove -l t/cpanrt.t → 26/26 tests pass
  • prove -l t/ → 977/977 tests pass

Generated 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

@atoomic
Copy link
Copy Markdown
Collaborator

atoomic commented Mar 15, 2026

@Koan-Bot rebase

@Koan-Bot
Copy link
Copy Markdown
Author

Rebase: fix: str2time maps 4-digit pre-1970 years to future (RT#84075/GH#12)

Branch koan.atoomic/fix-issue-12 rebased onto main and force-pushed.

Diff: 58 files changed, 2417 insertions(+), 1414 deletions(-)

Review feedback was analyzed and applied.

Actions

  • Rebased koan.atoomic/fix-issue-12 onto origin/main
  • Force-pushed koan.atoomic/fix-issue-12 to origin

Automated by Kōan

@atoomic atoomic self-assigned this Mar 18, 2026
@atoomic atoomic marked this pull request as ready for review March 18, 2026 02:55
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>
@Koan-Bot Koan-Bot force-pushed the koan.atoomic/fix-issue-12 branch from 1e7c9aa to 2fbb87b Compare March 18, 2026 03:02
@atoomic atoomic merged commit 999be82 into cpan-authors:main Mar 18, 2026
22 checks passed
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.

Date::Parse::str2time maps date in 1963 to 2063 [rt.cpan.org #84075]

2 participants