Skip to content

fix: Date::Language::str2time ignores EPOCH parameter#136

Draft
Koan-Bot wants to merge 1 commit intocpan-authors:mainfrom
Koan-Bot:koan.atoomic/fix-language-str2time-epoch
Draft

fix: Date::Language::str2time ignores EPOCH parameter#136
Koan-Bot wants to merge 1 commit intocpan-authors:mainfrom
Koan-Bot:koan.atoomic/fix-language-str2time-epoch

Conversation

@Koan-Bot
Copy link
Copy Markdown

@Koan-Bot Koan-Bot commented May 5, 2026

What

Makes Date::Language::str2time honor the optional EPOCH reference parameter, matching Date::Parse::str2time behavior.

Why

Date::Parse::str2time($date, $zone, $epoch) uses $epoch as the reference time when inferring missing year/month/day components. The equivalent Date::Language method silently discarded this parameter, always using time(). 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 to strptime — same pattern already used in Date::Parse::str2time.

Testing

Added test cases to t/lang-str2time.t verifying 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

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>
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.

1 participant