30 lines
998 B
PHP
30 lines
998 B
PHP
<?php
|
|
namespace Module\ACM\Classe\Classe\GestionDate;
|
|
|
|
use DateTime;
|
|
|
|
class GestionPeriode {
|
|
private DateTime $jourDebut;
|
|
private DateTime $jourFin;
|
|
public function __construct(DateTime $jourDebut, DateTime $jourFin) {
|
|
$this->jourDebut = $jourDebut;
|
|
$this->jourFin = $jourFin;
|
|
}
|
|
public function getNbDemiJournnees(){
|
|
$this->jourFin ->modify('+1 day');
|
|
$interval = (($this->jourDebut->diff($this->jourFin))->days)*2;
|
|
if ( $this->jourDebut->format("Y-m-d" )==$this->jourFin->format("Y-m-d")
|
|
&& $this->jourDebut->format("a" )==$this->jourFin->format("a")) {
|
|
$interval = $interval - 1;
|
|
} else {
|
|
if ( $this->jourDebut->format("a") == "pm") {$interval = $interval-1;}
|
|
if ( $this->jourFin->format("a") == "am") {$interval = $interval-1;}
|
|
}return $interval;
|
|
}
|
|
|
|
public function jourDansPeriode(DateTime $date) : bool {
|
|
return $this->jourDebut->format("Ymd")<=$date->format("Ymd")
|
|
&& $this->jourFin->format("Ymd")>=$date->format("Ymd");
|
|
}
|
|
}
|