Closed SeriousKen closed 7 months ago
This is fixed by changing the floor
method in the Date
class to the following:
public function floor(string $unit): static
{
static::validateUnit($unit);
$formats = [
'year' => 'Y-01-01',
'month' => 'Y-m-01',
'day' => 'Y-m-d',
'hour' => 'Y-m-d H:00:00',
'minute' => 'Y-m-d H:i:00',
'second' => 'Y-m-d H:i:s'
];
$flooredDate = $this->format($formats[$unit]);
$this->set($flooredDate);
return $this;
}
This passes all current tests and it doesn't matter what the default timezone is set to in php.ini, however, I think there should be some new test cases added covering different timezones to prevent regression.
Description
Unit test
DateTest::testRound
fails whendefault_timezone
is not UTC.To reproduce
default.timezone = Europe/London
in php.iniphpunit --filter DateTest
See error