diff options
Diffstat (limited to 'tests/units/Core/DateParserTest.php')
-rw-r--r-- | tests/units/Core/DateParserTest.php | 20 |
1 files changed, 6 insertions, 14 deletions
diff --git a/tests/units/Core/DateParserTest.php b/tests/units/Core/DateParserTest.php index fbde8bd5..e0dfb4c1 100644 --- a/tests/units/Core/DateParserTest.php +++ b/tests/units/Core/DateParserTest.php @@ -64,7 +64,7 @@ class DateParserTest extends Base $dates = $dateParser->getDateTimeFormats(true); $this->assertEquals('m/d/Y H:i', $dates[0]); - $this->container['configModel']->save(array('application_datetime_format' => 'd/m/Y g:i a')); + $this->container['configModel']->save(array('application_date_format' => 'd/m/Y', 'application_time_format' => 'g:i a')); $this->container['memoryCache']->flush(); $dates = $dateParser->getDateTimeFormats(); @@ -121,7 +121,7 @@ class DateParserTest extends Base { $this->container['configModel']->save(array( 'application_date_format' => 'd/m/Y', - 'application_datetime_format' => 'd/m/Y g:i a', + 'application_time_format' => 'g:i a', )); $dateParser = new DateParser($this->container); @@ -138,7 +138,7 @@ class DateParserTest extends Base { $this->container['configModel']->save(array( 'application_date_format' => 'd.m.Y', - 'application_datetime_format' => 'd.m.Y H:i', + 'application_time_format' => 'H:i', )); $dateParser = new DateParser($this->container); @@ -166,17 +166,9 @@ class DateParserTest extends Base $this->assertEquals(1, $dateParser->getHours(new DateTime('2015-03-14 15:00:00'), new DateTime('2015-03-14 16:00:00'))); $this->assertEquals(2.5, $dateParser->getHours(new DateTime('2015-03-14 15:00:00'), new DateTime('2015-03-14 17:30:00'))); $this->assertEquals(2.75, $dateParser->getHours(new DateTime('2015-03-14 15:00:00'), new DateTime('2015-03-14 17:45:00'))); - $this->assertEquals(3, $dateParser->getHours(new DateTime('2015-03-14 14:57:00'), new DateTime('2015-03-14 17:58:00'))); - $this->assertEquals(3, $dateParser->getHours(new DateTime('2015-03-14 14:57:00'), new DateTime('2015-03-14 11:58:00'))); - } - - public function testRoundSeconds() - { - $dateParser = new DateParser($this->container); - $this->assertEquals('16:30', date('H:i', $dateParser->getRoundedSeconds(strtotime('16:28')))); - $this->assertEquals('16:00', date('H:i', $dateParser->getRoundedSeconds(strtotime('16:02')))); - $this->assertEquals('16:15', date('H:i', $dateParser->getRoundedSeconds(strtotime('16:14')))); - $this->assertEquals('17:00', date('H:i', $dateParser->getRoundedSeconds(strtotime('16:58')))); + $this->assertEquals(3.02, $dateParser->getHours(new DateTime('2015-03-14 14:57:00'), new DateTime('2015-03-14 17:58:00'))); + $this->assertEquals(2.98, $dateParser->getHours(new DateTime('2015-03-14 14:57:00'), new DateTime('2015-03-14 11:58:00'))); + $this->assertEquals(0, $dateParser->getHours(new DateTime('2015-03-14 14:57:00'), new DateTime('2015-03-14 14:57:10'))); } public function testGetIsoDate() |