Correcting database input value for midnight on 12-hour display, fixes #3927

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6399 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
nate 2008-01-21 12:53:37 +00:00
parent 943eaf7549
commit 7e3a30fd85
2 changed files with 6 additions and 0 deletions

View file

@ -1316,6 +1316,8 @@ class FormHelper extends AppHelper {
if (($check > 115959) && $timeFormat == '12') {
$time[0] = $time[0] - 12;
$meridian = 'pm';
} elseif ($time[0] == '00' && $timeFormat == '12') {
$time[0] = 12;
} elseif ($time[0] > 12) {
$meridian = 'pm';
}

View file

@ -1008,6 +1008,10 @@ class FormHelperTest extends CakeTestCase {
$result = $this->Form->dateTime('Contact.date', 'DMY', '12');
$this->assertPattern('/<option\s+value=""[^>]*>/', $result);
$this->assertNoPattern('/<option[^<>]+selected="selected"[^>]*>/', $result);
$this->Form->data['Model']['field'] = '2008-01-01 00:00:00';
$result = $this->Form->dateTime('Model.field', 'DMY', '12', null, array(), false);
$this->assertPattern('/option value="12" selected="selected"/', $result);
}
function testMonth() {