mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-09-08 20:42:42 +00:00
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:
parent
f6c3015705
commit
64da4e75c4
1 changed files with 5 additions and 10 deletions
|
@ -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])) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue