Skip to content

Commit

Permalink
Typo for calendar.
Browse files Browse the repository at this point in the history
  • Loading branch information
Milan Matejcek committed Jan 18, 2015
1 parent 538cea5 commit 313b5c6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
7 changes: 5 additions & 2 deletions src/Date/Calendar.php
Expand Up @@ -116,7 +116,7 @@ public static function nameOfMonth($month = NULL)
* @param string $date CZECH FORMAT DD.MM.YYYY[ HH:mm:SS]
* @return DateTime
*/
public static function czechDate2Sql($date)
public static function czech2DateTime($date)
{
if (!preg_match('/^(?P<d>[0-3]?\d)\.(?P<m>[0-1]?\d)\.(?P<y>\d{4})(?: +(?P<h>[0-6]?\d):(?P<i>[0-6]?\d)(?::(?P<s>[0-6]?\d))?)?$/', trim($date), $find)) {
throw new DataTypeException('Bad czech date format. ' . $date);
Expand All @@ -133,11 +133,14 @@ public static function czechDate2Sql($date)
/**
* Number days of February.
*
* @param int $year
* @param int|DateTime $year
* @return int
*/
public static function februaryOfDay($year)
{
if ($year instanceof DateTime) {
$year = $year->format('Y');
}
return checkdate(2, 29, $year) ? 29 : 28;
}

Expand Down
22 changes: 11 additions & 11 deletions tests/src/Date/CalendarTest.php
Expand Up @@ -57,38 +57,38 @@ public function testNameOfMonth()
}

/**
* @covers h4kuna\DataType\Date\Calendar::czechDate2Sql
* @covers h4kuna\DataType\Date\Calendar::czech2DateTime
* @todo Implement testCzechDate2Sql().
*/
public function testCzechDate2Sql()
public function testCzech2DateTime()
{
$format = 'Y-m-d';
$dt = Calendar::czechDate2Sql('1.1.1986');
$dt = Calendar::czech2DateTime('1.1.1986');
$this->assertSame('1986-01-01', $dt->format($format));

$dt = Calendar::czechDate2Sql('01.1.1986');
$dt = Calendar::czech2DateTime('01.1.1986');
$this->assertSame('1986-01-01', $dt->format($format));

$dt = Calendar::czechDate2Sql('01.01.1986');
$dt = Calendar::czech2DateTime('01.01.1986');
$this->assertSame('1986-01-01', $dt->format($format));

$dt = Calendar::czechDate2Sql('30.12.1986');
$dt = Calendar::czech2DateTime('30.12.1986');
$this->assertSame('1986-12-30', $dt->format($format));

$format .= ' H:i:s';
$dt = Calendar::czechDate2Sql('01.01.1986 01:01:01');
$dt = Calendar::czech2DateTime('01.01.1986 01:01:01');
$this->assertSame('1986-01-01 01:01:01', $dt->format($format));

$dt = Calendar::czechDate2Sql('01.01.1986 1:1:1');
$dt = Calendar::czech2DateTime('01.01.1986 1:1:1');
$this->assertSame('1986-01-01 01:01:01', $dt->format($format));

$dt = Calendar::czechDate2Sql('01.01.1986 1:01:01');
$dt = Calendar::czech2DateTime('01.01.1986 1:01:01');
$this->assertSame('1986-01-01 01:01:01', $dt->format($format));

$dt = Calendar::czechDate2Sql('30.12.1986 23:59:59');
$dt = Calendar::czech2DateTime('30.12.1986 23:59:59');
$this->assertSame('1986-12-30 23:59:59', $dt->format($format));

$dt = Calendar::czechDate2Sql('30.12.1986 23:59');
$dt = Calendar::czech2DateTime('30.12.1986 23:59');
$this->assertSame('1986-12-30 23:59:00', $dt->format($format));
}

Expand Down

0 comments on commit 313b5c6

Please sign in to comment.