Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions test/Unnamespaced/DateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -726,4 +726,55 @@ public function testIntegerTimestampNoDeprecation(): void
$date = new Horde_Date(-631152000);
$this->assertEquals(1950, $date->year);
}

/**
* Test numeric timestamp string handling (deprecated BC support)
*
* DEPRECATED: SOME numeric strings are silently accepted for BC compatibility.
* This behavior will be removed in next major version.
* Callers should pass objects or integer timestamps instead.
*
* The Horde_Date constructor is the wrong place to guess what a caller means.
*
* @link https://github.com/horde/Date/issues/6
* @link https://github.com/horde/ActiveSync/pull/15
*/
public function testNumericTimestampStringDeprecated(): void
{
// Pre-1970 timestamp as string - accepted for BC
$date = new Horde_Date('-631152000'); // 1950-01-01
$this->assertEquals(1950, $date->year);
$this->assertEquals(1, $date->month);
$this->assertEquals(1, $date->mday);
}

/**
* Test positive numeric timestamp string (deprecated BC support)
*
* @link https://github.com/horde/Date/issues/6
* @link https://github.com/horde/ActiveSync/pull/15
*/
public function testPositiveNumericTimestampStringDeprecated(): void
{
$date = new Horde_Date('1773944669'); // 2026-03-19 (from ActiveSync PR)
$this->assertEquals(2026, $date->year);
$this->assertEquals(3, $date->month);
$this->assertEquals(19, $date->mday);
}

/**
* Test that integer timestamps still work without deprecation
*
* @link https://github.com/horde/Date/issues/6
*/
public function testIntegerTimestampNoDeprecation(): void
{
// Should NOT trigger deprecation
$date = new Horde_Date(1773944669);
$this->assertEquals(2026, $date->year);

// Pre-1970 integer
$date = new Horde_Date(-631152000);
$this->assertEquals(1950, $date->year);
}
}
Loading