kopia lustrzana https://github.com/friendica/SG-iCalendar
code cleanup
rodzic
f9e8612eb6
commit
e03b95f43d
|
@ -138,11 +138,11 @@ class SG_iCal_Freq {
|
|||
* @return int
|
||||
*/
|
||||
public function findNext($offset) {
|
||||
$echo = false;
|
||||
$debug = false;
|
||||
|
||||
//make sure the offset is valid
|
||||
if( $offset === false || (isset($this->rules['until']) && $offset > $this->rules['until']) ) {
|
||||
if($echo) echo 'STOP: ' . date('r', $offset) . "\n";
|
||||
if($debug) echo 'STOP: ' . date('r', $offset) . "\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -150,11 +150,11 @@ class SG_iCal_Freq {
|
|||
|
||||
//set the timestamp of the offset (ignoring hours and minutes unless we want them to be
|
||||
//part of the calculations.
|
||||
if($echo) echo 'O: ' . date('r', $offset) . "\n";
|
||||
if($debug) echo 'O: ' . date('r', $offset) . "\n";
|
||||
$hour = (in_array($this->freq, array('hourly','minutely')) && $offset > $this->start) ? date('H', $offset) : date('H', $this->start);
|
||||
$minute = (($this->freq == 'minutely' || isset($this->rules['byminute'])) && $offset > $this->start) ? date('i', $offset) : date('i', $this->start);
|
||||
$t = mktime($hour, $minute, date('s', $this->start), date('m', $offset), date('d', $offset), date('Y',$offset));
|
||||
if($echo) echo 'START: ' . date('r', $t) . "\n";
|
||||
if($debug) echo 'START: ' . date('r', $t) . "\n";
|
||||
|
||||
if( $this->simpleMode ) {
|
||||
if( $offset < $t ) {
|
||||
|
@ -168,7 +168,7 @@ class SG_iCal_Freq {
|
|||
}
|
||||
|
||||
$eop = $this->findEndOfPeriod($offset);
|
||||
if($echo) echo 'EOP: ' . date('r', $eop) . "\n";
|
||||
if($debug) echo 'EOP: ' . date('r', $eop) . "\n";
|
||||
|
||||
foreach( $this->knownRules AS $rule ) {
|
||||
if( $found && isset($this->rules['by' . $rule]) ) {
|
||||
|
@ -180,7 +180,7 @@ class SG_iCal_Freq {
|
|||
if( $imm === false ) {
|
||||
break;
|
||||
}
|
||||
if($echo) echo strtoupper($rule) . ': ' . date('r', $imm) . ' A: ' . ((int) ($imm > $offset && $imm < $eop)) . "\n";
|
||||
if($debug) echo strtoupper($rule) . ': ' . date('r', $imm) . ' A: ' . ((int) ($imm > $offset && $imm < $eop)) . "\n";
|
||||
if( $imm > $offset && $imm < $eop && ($_t == null || $imm < $_t) ) {
|
||||
$_t = $imm;
|
||||
}
|
||||
|
@ -198,14 +198,14 @@ class SG_iCal_Freq {
|
|||
return $this->start;
|
||||
} else if( $found && ($t != $offset)) {
|
||||
if( $this->validDate( $t ) ) {
|
||||
if($echo) echo 'OK' . "\n";
|
||||
if($debug) echo 'OK' . "\n";
|
||||
return $t;
|
||||
} else {
|
||||
if($echo) echo 'Invalid' . "\n";
|
||||
if($debug) echo 'Invalid' . "\n";
|
||||
return $this->findNext($t);
|
||||
}
|
||||
} else {
|
||||
if($echo) echo 'Not found' . "\n";
|
||||
if($debug) echo 'Not found' . "\n";
|
||||
return $this->findNext( $this->findStartingPoint( $offset, $this->rules['interval'] ) );
|
||||
}
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue