Skip to content
Permalink
Browse files

Remove silly code.

Changing the 12'th hour into 0 shouldn't be done when figuring out the
meridian, it makes sorting things out later more complicated. Remove
some duplicated code.
  • Loading branch information...
markstory committed Apr 20, 2013
1 parent f6c3015 commit 64da4e75c439680af6baa66ec340ee02c26a295a
Showing with 5 additions and 10 deletions.
  1. +5 −10 lib/Cake/View/Helper/FormHelper.php
@@ -2374,13 +2374,16 @@ public function dateTime($fieldName, $dateFormat = 'DMY', $timeFormat = '12', $a
$monthNames = $attributes['monthNames'];
$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) {
$current->setDate($year, $month, $day);
}
if ($hour !== null) {
$hour = $timeFormat == 12 && $hour == 12 ? 0 : $hour;
$current->setTime($hour, $min);
}
$change = (round($min * (1 / $interval)) * $interval) - $min;
@@ -2506,16 +2509,8 @@ protected function _getDateTimeValue($value, $timeFormat) {
if (!empty($timeFormat)) {
$time = explode(':', $days[1]);
// TODO this code is stupid.
if ($time[0] >= 12 && $timeFormat == 12) {
if ($time[0] >= 12) {
$meridian = 'pm';
} elseif ($time[0] === '00' && $timeFormat == 12) {
$time[0] = 12;
} elseif ($time[0] >= 12) {
$meridian = 'pm';
}
if ($time[0] == 0 && $timeFormat == 12) {
$time[0] = 12;
}
$hour = $min = null;
if (isset($time[1])) {

0 comments on commit 64da4e7

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