PEAR is discontinued

This is a static archive preserving historical releases and metadata. No new packages or updates will be published. For updates to existing packages, or to publish new packages, please use Composer and Packagist.

Home » Date and Time » Calendar » Bug #5236

isEmpty() Bug

Details

Submitted2005-08-29 15:19 UTC
Fromzoullou77 at gmail dot com
Assignedquipo
StatusBogus
PackageCalendar
PHP VersionIrrelevant
Roadmaps(Not assigned)

Comments

[2005-08-29 15:19 UTC] zoullou77 at gmail dot com

Description:
------------
With Calendar_Month_Weeks :

Selected day : 2005/08/29
On 2005/09 month, 2005/08/29 isEmpty() return false

Test script:
---------------
$selectedDays = array(new Calendar_Day(2005,8,29));

$Month = new Calendar_Month_Weeks(2005,9);
$Month->build();
$Week = $Month->fetch();
$Week->build($selectedDays);
$Day = $Week->fetch();
echo $Day->isEmpty();

Expected result:
----------------
True

Actual result:
--------------
False

To have right result, must add 1 more test on Calendar_Week::setSelection($sDates) like this :

function setSelection($sDates)
{
foreach ($sDates as $sDate) {

foreach ($this->children as $key => $child) {

if ($child->thisDay() == $sDate->thisDay() &&

$child->thisMonth() == $sDate->thisMonth() &&

$child->thisYear() == $sDate->thisYear() &&

/* Test added */ !$child->isEmpty()
) {

$this->children[$key] = $sDate;

$this->children[$key]->setSelected();

}

}

}

reset($this->children);

}