/** * {@inheritdoc} */ public function getDate() { if ($this->date === NULL) { $this->date = $this->prototype->setTime(0, 0, 0); } return $this->date; }
/** * Set first and last days of accounting year * * @param \DateTimeImmutable $firstDay First day of accounting year * @param \DateTimeImmutable $lastDay Last day of accounting year * @return self Instance to enable chaining */ public function setAccountingYear(\DateTimeImmutable $firstDay, \DateTimeImmutable $lastDay) : self { $firstDay->setTime(0, 0, 0); $lastDay->setTime(23, 59, 59); $this->accountingYear = [$firstDay, $lastDay]; return $this; }
/** * {@inheritdoc} */ public function getCurrentDate() { return $this->fixedDateTime->setTime(0, 0, 0); }
public function testSetTime() { $time = '2000-01-02T03:14:25'; $immutable = new DateTimeImmutable($time); $control = new DateTimeImmutable($time); $mutable = new DateTime($time); $new = $immutable->setTime(2005, 10, 5); $mutable->setTime(2005, 10, 5); $this->assertNotSame($immutable, $new); $this->assertSame($control->format(DateTime::RFC3339), $immutable->format(DateTime::RFC3339)); $this->assertSame($mutable->format(DateTime::RFC3339), $new->format(DateTime::RFC3339)); }