Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix select hours for 0/12 #1257

Merged
merged 1 commit into from
Apr 30, 2013
Merged

fix select hours for 0/12 #1257

merged 1 commit into from
Apr 30, 2013

Conversation

dereuromark
Copy link
Member

for hour 12 (e.g. local time 14 at UTC+2) the tests fail as -= 12 casts to 0 and the === '00' check is not triggered.

see http://ci.cakephp.org/job/CakePHP%202.3%20-%20MySQL/993/ etc

@lorenzo
Copy link
Member

lorenzo commented Apr 30, 2013

this probably the most problematic line in CakePHP

@dereuromark
Copy link
Member Author

Yeah, probably. Would it be better to cast to int right away?

@@ -2207,7 +2207,7 @@ public function hour($fieldName, $format24Hours = false, $attributes = array())
if ($attributes['value'] > 12 && !$format24Hours) {
$attributes['value'] -= 12;
}
if ($attributes['value'] === '00' && !$format24Hours) {
if (($attributes['value'] === 0 || $attributes['value'] === '00') && !$format24Hours) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would a loose equality to 0 be more durable in the long run?

@markstory
Copy link
Member

An int cast is probably the best option imo.

@markstory
Copy link
Member

I did some quick tests locally and an int cast is a bad idea, as '', null and false all match at that point.

markstory added a commit that referenced this pull request Apr 30, 2013
@markstory markstory merged commit 9b7cd02 into cakephp:master Apr 30, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants