fix: Date::Language::str2time ignores EPOCH parameter#136
Draft
Koan-Bot wants to merge 1 commit intocpan-authors:mainfrom
Draft
fix: Date::Language::str2time ignores EPOCH parameter#136Koan-Bot wants to merge 1 commit intocpan-authors:mainfrom
Koan-Bot wants to merge 1 commit intocpan-authors:mainfrom
Conversation
Date::Parse::str2time accepts an optional third argument (EPOCH) used as the reference time when inferring missing date components. The equivalent method in Date::Language silently discarded this parameter, always using time() as the reference. This caused inconsistent behavior: parsing "25 Dec" with a July 2024 reference returned Dec 2023 via Date::Parse but Dec 2025 (current year minus one) via Date::Language. Fix: extract the EPOCH parameter before calling strptime, matching the Date::Parse implementation pattern. Co-Authored-By: Claude Opus 4.6 <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.
What
Makes
Date::Language::str2timehonor the optional EPOCH reference parameter, matchingDate::Parse::str2timebehavior.Why
Date::Parse::str2time($date, $zone, $epoch)uses$epochas the reference time when inferring missing year/month/day components. The equivalentDate::Languagemethod silently discarded this parameter, always usingtime(). This caused inconsistent results between the two APIs for dates without an explicit year.How
One-line fix: extract the third argument with
splice(@_, 2, 1)before passing the remaining args tostrptime— same pattern already used inDate::Parse::str2time.Testing
Added test cases to
t/lang-str2time.tverifying EPOCH-relative inference matches Date::Parse behavior. Full test suite passes.Quality Report
Changes: 2 files changed, 43 insertions(+), 1 deletion(-)
Code scan: clean
Tests: skipped
Branch hygiene: clean
Generated by Kōan post-mission quality pipeline