Skip to content
Permalink
Browse files

Fix 12PM not validating with string data.

In 252267c strict equality was used which excludes string '12'.

Refs #7430
  • Loading branch information...
markstory committed Sep 29, 2015
1 parent ef79994 commit 2716bcb81b3bc94368e30aafa6a7723bf8bb5620
Showing with 12 additions and 3 deletions.
  1. +1 −1 src/Validation/Validation.php
  2. +11 −2 tests/TestCase/Validation/ValidationTest.php
@@ -1203,7 +1203,7 @@ protected static function _getDateString($value)
if (isset($value['hour'])) {
if (isset($value['meridian'])) {
if ($value['hour'] === 12) {
if ((int)$value['hour'] === 12) {
$value['hour'] = 0;
}
$value['hour'] = strtolower($value['meridian']) === 'am' ? $value['hour'] : $value['hour'] + 12;
@@ -1,7 +1,5 @@
<?php
/**
* ValidationTest file
*
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
*
@@ -1470,6 +1468,17 @@ public function testDateArray()
*/
public function testDateTimeArray()
{
$date = [
'year' => 2014,
'month' => '02',
'day' => '14',
'hour' => '12',
'minute' => '14',
'second' => '15',
'meridian' => 'pm'
];
$this->assertTrue(Validation::datetime($date));
$date = ['year' => 2014, 'month' => 2, 'day' => 14, 'hour' => 13, 'minute' => 14, 'second' => 15];
$this->assertTrue(Validation::datetime($date));

0 comments on commit 2716bcb

Please sign in to comment.
You can’t perform that action at this time.