Home » Date and Time » Calendar » Bug #2418
Year:build() setting start of week does not work
Details
| Submitted | 2004-09-30 11:28 UTC |
|---|---|
| From | chris at deskpro dot com |
| Assigned | quipo |
| Status | Closed |
| Package | Calendar |
| PHP Version | 4.3.6 |
| OS | Win - but not relevant |
| Roadmaps | (Not assigned) |
Comments
[2004-09-30 11:28 UTC] chris at deskpro dot com
Description:
------------
http://pear.php.net/manual/en/package.datetime.calendar.calendar-year.build.php
The function build() is meant to accept the firstDay variable as 2nd parameter to set the start day of week. This has no affect. You cansee from the following ode that if the $firstDay variable is set, nothing is every done with it.
One fix for this is just to do a define at the start of your file based on CALENDAR_FIRST_DAY_OF_WEEK as this affects the factory method that creates the months in the year class.
Either way this is all a little confusing, it seems some places you are meant to pass start of the week in build function, sometimes in the constructor and sometimes you might have to use a define. Perhaps these methods can all be reconcilled somehow? I personally think that using a CONSTANT that affects all classes would be best, i can't imagine a situation you would want to display a calendar with two different week starts on the same page.
Reproduce code:
---------------
The function that does nothing when the variable is set:
function build($sDates = array(), $firstDay = null)
{
require_once CALENDAR_ROOT.'Factory.php';
if (is_null($firstDay)) {
$firstDay = $this->cE->getFirstDayOfWeek(
$this->thisYear(),
$this->thisMonth(),
$this->thisDay()
);
}
$monthsInYear = $this->cE->getMonthsInYear($this->thisYear());
for ($i=1; $i <= $monthsInYear; $i++) {
$this->children[$i] = Calendar_Factory::create('Month',$this->year,$i);
}
if (count($sDates) > 0) {
$this->setSelection($sDates);
}
return true;
}
[2004-10-01 20:28 UTC] chris at deskpro dot com
Yeah, thats what I did :)
[2005-01-13 02:47 UTC] chris at deskpro dot com
Just wondering if any changes have been made in CVS to unify the ways to set the start of the week?