cmswest wrote on Saturday, July 26, 2014:
almost, try below, # sign comments out the code:
on the 2nd point, it looks like Brady created a eng subfolder for translations, etc.
same approach could be used to add one for l’afrique if in demand
/**
* __increment()
* returns the next valid date for an event based on the
* current day,month,year,freq and type
* @private
* @returns string YYYY-MM-DD
*/
function &__increment($d,$m,$y,$f,$t)
{
if($t == REPEAT_EVERY_DAY) {
return date('Y-m-d',mktime(0,0,0,$m,($d+$f),$y));
} elseif($t == REPEAT_EVERY_WORK_DAY) {
// a workday is defined as Mon,Tue,Wed,Thu,Fri
// repeating on every or Nth work day means to not include
// weekends (Sat/Sun) in the increment... tricky
// ugh, a day-by-day loop seems necessary here, something where
// we can check to see if the day is a Sat/Sun and increment
// the frequency count so as to ignore the weekend. hmmmm....
$orig_freq = $f;
for ($daycount=1; $daycount<=$orig_freq; $daycount++) {
$nextWorkDOW = date('D',mktime(0,0,0,$m,($d+$daycount),$y));
if ($nextWorkDOW == "Fri") { $f++; }
# else if ($nextWorkDOW == "Sun") { $f++; }
}
// and finally make sure we haven't landed on a Sat/Sun
// adjust as necessary
$nextWorkDOW = date('D',mktime(0,0,0,$m,($d+$f),$y));
if ($nextWorkDOW == "Fri") { $f++; }
# else if ($nextWorkDOW == "Sun") { $f++; }
return date('Y-m-d',mktime(0,0,0,$m,($d+$f),$y));
} elseif($t == REPEAT_EVERY_WEEK) {
return date('Y-m-d',mktime(0,0,0,$m,($d+(7*$f)),$y));
} elseif($t == REPEAT_EVERY_MONTH) {
return date('Y-m-d',mktime(0,0,0,($m+$f),$d,$y));
} elseif($t == REPEAT_EVERY_YEAR) {
return date('Y-m-d',mktime(0,0,0,$m,$d,($y+$f)));
}
}
//==================================================================================================