Une correction dans le Nb de jours restant avant la prochaine saison et un ajout pour la classe saison: méthode pour calculer depuis combien de temps on est dans la saison
Code : Tout sélectionner
public function getSeasonNbDays() {
$p = $this->getPhase();
$d = $this->getDate($p); // Date of Phase start
if ($d > $this->_date) { //we are before March's phase 1
$x = new Season(substr($this->_date,0,4)-1);
$d = $x->getDate(4); // getdate for phase 4 last year
}
$d2 = strftime('%d-%m-%Y',strtotime($d));
$d1 = strftime('%d-%m-%Y',strtotime($this->_date));
$delta = round((strtotime($d2) - strtotime($d1))/86400);
return -$delta;
//echo $this->_date." to ".$d." = ".$delta;
}
public function getNextSeasonNbDays() {
$p = $this->getPhase();
$d = $this->getDate($p%4+1); // Date of next phase
if ($d < $this->_date) { //we are in december
$x = new Season(substr($this->_date,0,4)+1);
$d = $x->getDate(1); // getdate for phase 1 next year
}
$d2 = strftime('%d-%m-%Y',strtotime($d));
$d1 = strftime('%d-%m-%Y',strtotime($this->_date));
$delta = round((strtotime($d2) - strtotime($d1))/86400);
return $delta;
//echo $this->_date." to ".$d." = ".$delta;
}
Diving91Today 2015-08-18 we are in Summer since 58days. It remains 36days before Fall