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

Better number format with CakeNumber #1986

Closed
ghost opened this issue Oct 11, 2013 · 8 comments
Closed

Better number format with CakeNumber #1986

ghost opened this issue Oct 11, 2013 · 8 comments
Milestone

Comments

@ghost
Copy link

ghost commented Oct 11, 2013

Created by Ingo Siebeck, 31st Aug 2012. (originally Lighthouse ticket #3170):


At the moment, the CakeNumber Class seems to be more for money and currency formating.

My problem was, that i want to format a Number like 2.00 to the german format 2,00 and cut the zeros, if the decimal part is zero.

i change the CakeNumber Class like this:

from:

if ($foundDecimal !== false) {
 $after = substr($number, $foundDecimal);
 $number = substr($number, 0, $foundDecimal);
}

into

if ($foundDecimal !== false && intval(substr($number, $foundDecimal + 1, strlen($number))) > 0) {
 $after = substr($number, $foundDecimal);
 $number = substr($number, 0, $foundDecimal);
} elseif (intval(substr($number, $foundDecimal + 1, strlen($number))) == 0) {
 $number = intval($number);
 $after = '';
}

any chance to get better formatting possibilities into this class?

@ghost
Copy link
Author

ghost commented Oct 11, 2013

31st Aug 2012, Mark Story said:


Patches with test cases are generally a good candidate for getting into CakePHP, also new features for 2.x have to not break existing behavior. This seems like the kind of behavior that could be controlled with a new option to the existing formatting methods. Or in a new formatting method.

@ghost
Copy link
Author

ghost commented Oct 11, 2013

31st Aug 2012, Ingo Siebeck said:


Yes, i think a new method would be the best. Because the existing is fine for all the money formatting stuff.

@ghost
Copy link
Author

ghost commented Oct 11, 2013

18th Jul 2013, euromark said:


if format() would not automatically append/prepend the currency, this would resolve it: #1431

@ravage84
Copy link
Member

Shouldn't we change the milestone for this to 3.0 because @dereuromark's PR wasn't merged?

@ravage84
Copy link
Member

Also, those three issues are very similar:
#1965
#1955
#1986

Probably those could be merged into one with a clear, updated goal and possibly a proposal how to implement (taking the discussion of #1431 into account).

@markstory
Copy link
Member

Did you want to make the new merged ticket?

@ravage84
Copy link
Member

I just think it would help to get a a more picture of what needs to be done.
But I let someone else with more insight and overview write that ticket....

@dereuromark dereuromark modified the milestones: 3.0.0, Future Jul 5, 2014
@markstory
Copy link
Member

Closing as number formatting has been revamped using ext/intl for 3.0. See #4086

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants