Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 0.5.5

Bug #1798 Week class doesn't support selections that span months
Submitted: 2004-07-05 16:04 UTC Modified: 2004-07-08 05:15 UTC
From: tj-pear at drennan dot bc dot ca Assigned: quipo
Status: Closed Package: Calendar
PHP Version: 4.3.4 OS: Win32/Linux/Mac OS X
Roadmaps: (Not assigned)    
Subscription  


 [2004-07-05 16:04 UTC] tj-pear at drennan dot bc dot ca
Description: ------------ The setSelection function in the Calendar/Week.php class checks to see if the object's year and month match each of the passed in selection dates. This check should be removed in order to allow support for selections that cross from one month and/or year into the following month/year because this check will fail which will prevent the selection from being done. Here is a new setSelection function which fixes this problem: 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()) { $this->children[$key] = $sDate; $this->children[$key]->setSelected(); } } } reset($this->children); } Note: This is note the same problem as Bug #1440 but that solution has been applied to the above function. Reproduce code: --------------- A test script (based on example 15) which demonstrates this can be found at: http://drennan.bc.ca/projects/pear/Calendar_Week_bug_test.phps The script builds a Week object using a date from the last partial week in Dec 2003 and another Week object using a date from the first partial week from Jan 2004. It then passes in a set of days that span the part of the Week in Dec 2003 and the part of the week in Jan 2004 to each of the weeks and verifies that all of the days are selected for each of the built week objects. Expected result: ---------------- All of the days of the week should be selected (indicated by a PASSED indicator given for the day) for both of the two tests in the test script. Actual result: -------------- For test 1 (using date from first month) only the days in that month are selected. For test 2 (using date from second month) only the days in that month are selected.

Comments

 [2004-07-08 05:15 UTC] quipo
This bug has been fixed in CVS. In case this was a documentation problem, the fix will show up at the end of next Sunday (CET) on pear.php.net. In case this was a pear.php.net website problem, the change will show up on the website in short time. Thank you for the report, and for helping us make PEAR better. -- Thanks for the patch and the excellent reproduce script!