Only call DateTimeFormat::fix() when there's an Exception

- This prevents valid date/time strings to be mangled by fix()
This commit is contained in:
Hypolite Petovan 2022-10-09 00:23:09 -04:00
parent b5ad8c3e15
commit bee6506d33
2 changed files with 29 additions and 17 deletions

View file

@ -141,4 +141,18 @@ class DateTimeFormatTest extends MockedTest
{
$this->assertEquals($expected, DateTimeFormat::fix($dateString));
}
/**
* This test is meant to ensure DateTimeFormat::fix() isn't called on relative date/time strings
*
* @return void
* @throws \Exception
*/
public function testConvertRelative()
{
$now = DateTimeFormat::utcNow('U');
$date = DateTimeFormat::utc('now - 3 days', 'U');
$this->assertEquals(259200, $now - $date);
}
}