Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Fixed a bug in the dateTime function of the form helper. #57

Closed
wants to merge 1 commit into from

2 participants

@romaimperator

I fixed a bug in the dateTime function that prevented the proper hour from being selected because the check for past noon required seconds to be set and they weren't. The view needed hour, minute, and meridian boxes and the time to be shown was 18:15. Debugging the value of $check showed that it was 1815 which is not greater than 115959 which prevented the 12 hours from being subtracted which then prevented the value of 6 from being selected by default in the HTML select box. This fix instead checks to see if the hours is greater than 12 and if so subtracts 12 and sets the meridian to PM.

@romaimperator romaimperator fixed a bug in the dateTime function that prevented the proper hour f…
…rom being selected because the check for past noon required seconds to be set and they weren't
2b4f14a
@markstory
Owner

How would one reproduce this issue? Without a way to reproduce its hard to write a test case.

@romaimperator

With this code for a view, model, and controller (https://gist.github.com/933435) and using a fresh download of CakePHP 1.3.8, I was able to get it to leave the default of 1 selected rather than the correct hour of 6.

@markstory markstory referenced this pull request from a commit
@markstory markstory Adding tests for GH-57 877c874
@markstory
Owner

Thanks for the patch, its been merged in. :)

@markstory markstory closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 20, 2011
  1. @romaimperator

    fixed a bug in the dateTime function that prevented the proper hour f…

    romaimperator authored
    …rom being selected because the check for past noon required seconds to be set and they weren't
This page is out of date. Refresh to see the latest.
Showing with 1 addition and 2 deletions.
  1. +1 −2  cake/libs/view/helpers/form.php
View
3  cake/libs/view/helpers/form.php
@@ -1826,9 +1826,8 @@ function dateTime($fieldName, $dateFormat = 'DMY', $timeFormat = '12', $selected
if (!empty($timeFormat)) {
$time = explode(':', $days[1]);
- $check = str_replace(':', '', $days[1]);
- if (($check > 115959) && $timeFormat == '12') {
+ if (($time[0] > 12) && $timeFormat == '12') {
$time[0] = $time[0] - 12;
$meridian = 'pm';
} elseif ($time[0] == '00' && $timeFormat == '12') {
Something went wrong with that request. Please try again.