From 2d428a66c7ea6dd24f350d270e26e368a7c30805 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Sun, 1 Aug 2004 13:15:26 +0000 Subject: [PATCH] fixed disapearing holidays caused by the observance rule, see bug [ 996820 ] Calendar Control - Missing Holidays --- calendar/inc/class.boholiday.inc.php | 10 +++----- calendar/inc/class.holidaycalc_US.inc.php | 28 +++++++++++------------ 2 files changed, 17 insertions(+), 21 deletions(-) diff --git a/calendar/inc/class.boholiday.inc.php b/calendar/inc/class.boholiday.inc.php index b1e4689298..50f2c6d990 100755 --- a/calendar/inc/class.boholiday.inc.php +++ b/calendar/inc/class.boholiday.inc.php @@ -387,9 +387,9 @@ } $temp_locale = $GLOBALS['phpgw_info']['user']['preferences']['common']['country']; - for($i=0;$i $holiday) + //for($i=0;$icalculate_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); diff --git a/calendar/inc/class.holidaycalc_US.inc.php b/calendar/inc/class.holidaycalc_US.inc.php index 434b76e13f..4994a3dc6f 100755 --- a/calendar/inc/class.holidaycalc_US.inc.php +++ b/calendar/inc/class.holidaycalc_US.inc.php @@ -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 "

holidaycalc::add(".print_r($holiday,True).",,$year,,$day_offset)=".print_r($holidays[$i],True)."

"; + $holidays[]= $holiday; + + //echo "

holidaycalc::add(,,$year,,$day_offset)=".print_r($holiday,True)."

"; } - function calculate_date($holiday, &$holidays, $year, &$i) + function calculate_date($holiday, &$holidays, $year) { //echo "

holidaycalc::calculate_date(".print_r($holiday,True).",,$year,)

"; @@ -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); } } }