Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix issue with midnight hour & 12hr formats.

No hour would be selected in the case of 12hr formats and a time like
00:xx:yy
  • Loading branch information...
commit f1d192f282486273d68c7334a18ebbd6f724cfce 1 parent 274a146
@markstory markstory authored
View
13 lib/Cake/Test/Case/View/Helper/FormHelperTest.php
@@ -2210,6 +2210,15 @@ public function testInputTime() {
$this->assertContains('<option value="06" selected="selected">6</option>', $result);
$this->assertContains('<option value="15" selected="selected">15</option>', $result);
$this->assertContains('<option value="pm" selected="selected">pm</option>', $result);
+
+ $result = $this->Form->input('published', array('type' => 'time'));
+ $now = strtotime('now');
+ $this->assertContains('<option value="' . date('h', $now) . '" selected="selected">' . date('g', $now) . '</option>', $result);
+
+ $now = strtotime('2013-03-09 00:42:21');
+ $result = $this->Form->input('published', array('type' => 'time', 'selected' => $now));
+ $this->assertContains('<option value="12" selected="selected">12</option>', $result);
+ $this->assertContains('<option value="42" selected="selected">42</option>', $result);
}
/**
@@ -5571,10 +5580,6 @@ public function testDateTime() {
$this->assertRegExp('/<option[^<>]+value="03"[^<>]+selected="selected"[^>]*>3<\/option>/', $result);
$this->assertRegExp('/<option[^<>]+value="13"[^<>]+selected="selected"[^>]*>13<\/option>/', $result);
$this->assertRegExp('/<option[^<>]+value="35"[^<>]+selected="selected"[^>]*>35<\/option>/', $result);
-
- $result = $this->Form->input('published', array('type' => 'time'));
- $now = strtotime('now');
- $this->assertContains('<option value="' . date('h', $now) . '" selected="selected">' . date('g', $now) . '</option>', $result);
}
/**
View
3  lib/Cake/View/Helper/FormHelper.php
@@ -2208,6 +2208,9 @@ public function hour($fieldName, $format24Hours = false, $attributes = array())
if ($attributes['value'] > 12 && !$format24Hours) {
$attributes['value'] -= 12;
}
+ if ($attributes['value'] === '00' && !$format24Hours) {
+ $attributes['value'] = 12;
+ }
return $this->select(
$fieldName . ".hour",
Please sign in to comment.
Something went wrong with that request. Please try again.