Permalink
Browse files

Fix incorrect default meridian

Prevent the default meridian from being changed from 'pm' to 'am' when the default time is in a 12-hour format between 1:00pm and 11:59pm and both a minute interval and default minute value are specified.
  • Loading branch information...
PhantomWatson committed Mar 14, 2013
1 parent 246c09a commit ec56d828b0615e10aaf22e3bd07cf6cb80a88775
Showing with 5 additions and 0 deletions.
  1. +5 −0 lib/Cake/View/Helper/FormHelper.php
@@ -2383,11 +2383,16 @@ public function dateTime($fieldName, $dateFormat = 'DMY', $timeFormat = '12', $a
$current->setDate($year, $month, $day);
}
if ($hour !== null) {
+ if ($timeFormat == '12') {
+ $hour = date('H', strtotime("$hour:$min $meridian"));
+ }
$current->setTime($hour, $min);
}
$change = (round($min * (1 / $interval)) * $interval) - $min;
$current->modify($change > 0 ? "+$change minutes" : "$change minutes");
$newTime = explode(' ', $current->format('Y m d H i a'));
+ $format = ($timeFormat == '12') ? 'Y m d h i a' : 'Y m d H i a';
+ $newTime = explode(' ', $current->format($format));
list($year, $month, $day, $hour, $min, $meridian) = $newTime;
}

0 comments on commit ec56d82

Please sign in to comment.