fixed disapearing holidays caused by the observance rule, see bug [ 996820 ] Calendar Control - Missing Holidays

This commit is contained in:
Ralf Becker 2004-08-01 13:15:26 +00:00
parent 9352bd53c4
commit 2d428a66c7
2 changed files with 17 additions and 21 deletions

View File

@ -387,9 +387,9 @@
}
$temp_locale = $GLOBALS['phpgw_info']['user']['preferences']['common']['country'];
for($i=0;$i<count($holidays);$i++)
foreach($holidays as $i => $holiday)
//for($i=0;$i<count($holidays);$i++)
{
$c = $i;
if($i == 0 || $holidays[$i]['locale'] != $holidays[$i - 1]['locale'])
{
if(is_object($holidaycalc))
@ -399,11 +399,7 @@
$GLOBALS['phpgw_info']['user']['preferences']['common']['country'] = $holidays[$i]['locale'];
$holidaycalc = CreateObject('calendar.holidaycalc');
}
$holidays[$i]['date'] = $holidaycalc->calculate_date($holidays[$i], $holidays, $this->year, $c);
if($c != $i)
{
$i = $c;
}
$holidays[$i]['date'] = $holidaycalc->calculate_date($holiday, $holidays, $this->year);
}
unset($holidaycalc);
$this->holidays = $this->sort_holidays_by_date($holidays);

View File

@ -15,25 +15,25 @@
class holidaycalc
{
function add($holiday,&$holidays,$year,&$i,$day_offset=0)
function add($holiday,&$holidays,$year,$day_offset=0)
{
$i++;
$holidays[$i]= $holiday;
if ($day_offset)
{
$holidays[$i]['name'] .= ' (Observed)';
$holiday['name'] .= ' (Observed)';
}
$holidays[$i]['date'] = mktime(0,0,0,$holiday['month'],$holiday['day']+$day_offset,$year);
$holiday['date'] = mktime(0,0,0,$holiday['month'],$holiday['day']+$day_offset,$year);
foreach(array('day'=>'d','month'=>'m','occurence'=>'Y') as $key => $frmt)
{
$holidays[$i][$key] = date($frmt,$holidays[$i]['date']);
$holiday[$key] = date($frmt,$holiday['date']);
}
$holidays[$i]['obervance_rule'] = 0;
$holiday['obervance_rule'] = 0;
//echo "<p>holidaycalc::add(".print_r($holiday,True).",,$year,,$day_offset)=".print_r($holidays[$i],True)."</p>";
$holidays[]= $holiday;
//echo "<p>holidaycalc::add(,,$year,,$day_offset)=".print_r($holiday,True)."</p>";
}
function calculate_date($holiday, &$holidays, $year, &$i)
function calculate_date($holiday, &$holidays, $year)
{
//echo "<p>holidaycalc::calculate_date(".print_r($holiday,True).",,$year,)</p>";
@ -71,7 +71,7 @@
// 0 = sundays are observed on monday (+1), 6 = saturdays are observed on fridays (-1)
if($dow == 0 || $dow == 6)
{
$this->add($holiday,$holidays,$year,$i,$dow == 0 ? 1 : -1);
$this->add($holiday,$holidays,$year,$dow == 0 ? 1 : -1);
}
if ($holiday['month'] == 1 && $day == 1)
{
@ -79,10 +79,10 @@
// checking if next year's newyear might be observed in this year
if ($dow == 6)
{
$this->add($holiday,$holidays,$year+1,$i,-1);
$this->add($holiday,$holidays,$year+1,-1);
}
// add the next years newyear, to show it in a week- or month-view
$this->add($holiday,$holidays,$year+1,$i);
$this->add($holiday,$holidays,$year+1);
}
// checking if last year's new year's eve might be observed in this year
if ($holiday['month'] == 12 && $day == 31)
@ -90,10 +90,10 @@
$dow = $GLOBALS['phpgw']->datetime->day_of_week($year-1,$holiday['month'],$day);
if ($dow == 0)
{
$this->add($holiday,$holidays,$year-1,$i,1);
$this->add($holiday,$holidays,$year-1,1);
}
// add the last years new year's eve, to show it in a week- or month-view
$this->add($holiday,$holidays,$year-1,$i);
$this->add($holiday,$holidays,$year-1);
}
}
}