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

Currency formatting issue #133

Open
easyitis opened this issue Jun 3, 2020 · 6 comments
Open

Currency formatting issue #133

easyitis opened this issue Jun 3, 2020 · 6 comments

Comments

@easyitis
Copy link

easyitis commented Jun 3, 2020

Using version 1.0.17. Some currencies are not getting formatted correctly.
Example:
currency(1,'USD','AED',true) => "دإ‏ 3,6731" (expected "دإ‏ 3.67")

@easyitis
Copy link
Author

easyitis commented Jun 5, 2020

On debugging it can be seen that this is where the issue is:

        // Match decimal and thousand separators
        preg_match_all('/[\s\',.!]/', $format, $separators);

        // NOTE: $separators is calculated as [" ", ",", "."]

        if ($thousand = Arr::get($separators, '0.0', null)) {
            if ($thousand == '!') {
                $thousand = '';
            }
        }

        $decimal = Arr::get($separators, '0.1', null);

This issue occurs whenever there's a space in the format code, for example:
AED: دإ‏ 1,0.00
ARS: $ 1,0.00

As an interim solution we can remove the spaces from all the format codes.

@AEK-BKF
Copy link

AEK-BKF commented Sep 23, 2020

Same issue with me, for SAR also

@easyitis
Copy link
Author

Same issue with me, for SAR also

Please try removing spaces from all the format codes.

@zpoll92
Copy link

zpoll92 commented Oct 14, 2020

Same issue here. Very annoying. If I remove the space then it doesn't look correct. @Torann can you please fix this ASAP?

@wrabit
Copy link

wrabit commented Oct 29, 2020

"fix this ASAP" for an open source package doesn't always go down well. If you see how you can fix it, consider a PR. But it's unfortunate and concerning to see there doesn't seem to be much activity on this project anymore. Maybe the maintainer can consider opening up sponsorship to motivate more work on it.

@Torann
Copy link
Owner

Torann commented Oct 29, 2020

Unfortunately I don't have time to look into this, but I will be more than happy to review a PR.

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

No branches or pull requests

5 participants