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.
This commit is contained in:
mark_story 2013-04-20 14:48:54 -04:00
parent f6c3015705
commit 64da4e75c4

View file

@ -2374,13 +2374,16 @@ class FormHelper extends AppHelper {
$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 @@ class FormHelper extends AppHelper {
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])) {