Skip to content

fix(date): accept DateTimeInterface in legacy Horde_Date constructor#17

Merged
ralflang merged 2 commits into
FRAMEWORK_6_0from
fix/date-datetimeinterface-legacy-constructor
Jun 24, 2026
Merged

fix(date): accept DateTimeInterface in legacy Horde_Date constructor#17
ralflang merged 2 commits into
FRAMEWORK_6_0from
fix/date-datetimeinterface-legacy-constructor

Conversation

@TDannhauer

Copy link
Copy Markdown
Contributor

Summary

  • Accept any DateTimeInterface in Horde_Date::_initializeFromObject()
  • Add regression tests for DateTimeImmutable and ICU-parsed dates

Motivation

Constructing Horde_Date from DateTimeImmutable (or from Horde\Date\Date::toDateTimeImmutable() after ICU parsing) fell through to invalid internal state (year -1), which broke Nag task saves and could export epoch due dates to ActiveSync.

Changes

  • lib/Horde/Date.php: use instanceof \DateTimeInterface in _initializeFromObject()
  • test/Unnamespaced/DateTest.php: cover immutable and parsed date construction

Test plan

  • vendor/bin/phpunit test/Unnamespaced/DateTest.php (constructor test)

_initializeFromObject() only handled DateTime, so DateTimeImmutable and
other DateTimeInterface values produced invalid years and broke saves
that flow through Nag and other legacy callers.

Add regression tests for DateTimeImmutable and parsed ICU dates.
@TDannhauer TDannhauer requested a review from ralflang June 23, 2026 21:08
@ralflang ralflang merged commit 5b1c0bf into FRAMEWORK_6_0 Jun 24, 2026
0 of 8 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.

2 participants