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

Add a .inCents() function #341

Open
graemetavour opened this issue Sep 10, 2021 · 3 comments
Open

Add a .inCents() function #341

graemetavour opened this issue Sep 10, 2021 · 3 comments

Comments

@graemetavour
Copy link

If you need to access the underlying value in cents (for instance to persist to a database or use in an API call), currently you need to use:

currency(valueInDollars).intValue;

It would be slightly more clear to be able to use:

currency(valueInDollars).inCents();

Not sure if inCents() is the best naming; could also consider toCentValue(), centValue(), valueInCents(), etc

@MikesGlitch
Copy link

MikesGlitch commented Oct 21, 2022

'subUnits' might be better to help remove api references to the US dollar/cents.

@raldred
Copy link

raldred commented Jan 20, 2023

How about currency(valueInMajorUnits).minorUnits?

@alexlukelevy
Copy link

If you had a precision > 2, then currency(valueInDollars).intValue would not equal cents either.

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

4 participants