From 5bddc477a399645b7d2c8135abb78c75d7feb9f2 Mon Sep 17 00:00:00 2001 From: mark_story Date: Thu, 19 Dec 2013 17:36:27 -0500 Subject: [PATCH] Fix incorrectly handled time values around 12:00:00 When using 12 hour formats & intervals, values around 12:00 were incorrecly converted to midnight. Fixes #2507 --- .../Test/Case/View/Helper/FormHelperTest.php | 37 +++++++++++++++++++ lib/Cake/View/Helper/FormHelper.php | 4 -- 2 files changed, 37 insertions(+), 4 deletions(-) diff --git a/lib/Cake/Test/Case/View/Helper/FormHelperTest.php b/lib/Cake/Test/Case/View/Helper/FormHelperTest.php index f1e4a25177d..4b504a97a6c 100644 --- a/lib/Cake/Test/Case/View/Helper/FormHelperTest.php +++ b/lib/Cake/Test/Case/View/Helper/FormHelperTest.php @@ -2347,6 +2347,43 @@ public function testTimeSelectedWithInterval() { $this->assertContains('', $result); } +/** + * Test time with selected values around 12:xx:xx + * + * @return void + */ + public function testTimeSelectedWithIntervalTwelve() { + $result = $this->Form->input('Model.start_time', array( + 'type' => 'time', + 'timeFormat' => 12, + 'interval' => 15, + 'selected' => '00:00:00' + )); + $this->assertContains('', $result); + $this->assertContains('', $result); + $this->assertContains('', $result); + + $result = $this->Form->input('Model.start_time', array( + 'type' => 'time', + 'timeFormat' => 12, + 'interval' => 15, + 'selected' => '12:00:00' + )); + $this->assertContains('', $result); + $this->assertContains('', $result); + $this->assertContains('', $result); + + $result = $this->Form->input('Model.start_time', array( + 'type' => 'time', + 'timeFormat' => 12, + 'interval' => 15, + 'selected' => '12:15:00' + )); + $this->assertContains('', $result); + $this->assertContains('', $result); + $this->assertContains('', $result); + } + /** * Test interval & timeFormat = 12 * diff --git a/lib/Cake/View/Helper/FormHelper.php b/lib/Cake/View/Helper/FormHelper.php index 8a37363b7bb..c168c004d17 100644 --- a/lib/Cake/View/Helper/FormHelper.php +++ b/lib/Cake/View/Helper/FormHelper.php @@ -2391,10 +2391,6 @@ public function dateTime($fieldName, $dateFormat = 'DMY', $timeFormat = '12', $a $round = $attributes['round']; $attributes = array_diff_key($attributes, $defaults); - if ($timeFormat == 12 && $hour == 12) { - $hour = 0; - } - if (!empty($interval) && $interval > 1 && !empty($min)) { $current = new DateTime(); if ($year !== null) {