Skip to content

Commit

Permalink
date controls: fixes reading parsed input as ints
Browse files Browse the repository at this point in the history
  • Loading branch information
hrach committed Aug 12, 2019
1 parent 44fa26a commit ca33c38
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions src/Controls/DateControl.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ protected function getDefaultParser()
return null;
}

$dd = $matches['dd'];
$mm = $matches['mm'];
$yyyy = $matches['yyyy'] ?? date('Y');
$dd = (int) $matches['dd'];
$mm = (int) $matches['mm'];
$yyyy = (int) ($matches['yyyy'] ?? date('Y'));

if (!checkdate($mm, $dd, $yyyy)) {
return null;
Expand Down
12 changes: 6 additions & 6 deletions src/Controls/DateTimeControl.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,17 @@ protected function getDefaultParser()
return null;
}

$dd = $matches['dd'];
$mm = $matches['mm'];
$yyyy = $matches['yyyy'] ?? date('Y');
$dd = (int) $matches['dd'];
$mm = (int) $matches['mm'];
$yyyy = (int) ($matches['yyyy'] ?? date('Y'));

if (!checkdate($mm, $dd, $yyyy)) {
return null;
}

$hh = $matches['hh'] ?? 0;
$ii = $matches['ii'] ?? 0;
$ss = $matches['ss'] ?? 0;
$hh = (int) ($matches['hh'] ?? 0);
$ii = (int) ($matches['ii'] ?? 0);
$ss = (int) ($matches['ss'] ?? 0);

if (!($hh >= 0 && $hh < 24 && $ii >= 0 && $ii <= 59 && $ss >= 0 && $ss <= 59)) {
return null;
Expand Down

0 comments on commit ca33c38

Please sign in to comment.