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

Support google.type.Money #226

Open
derekperkins opened this issue Sep 8, 2022 · 0 comments
Open

Support google.type.Money #226

derekperkins opened this issue Sep 8, 2022 · 0 comments

Comments

@derekperkins
Copy link

derekperkins commented Sep 8, 2022

There is already native helper support for google.protobuf.Timestamp, and while google.type.* aren't WKTs, they're pretty close. It should be pretty simple to generate similar helpers for money.

// Create our number formatter.
var formatter = new Intl.NumberFormat('en-US', {
  style: 'currency',
  currency: 'USD',

  // These options are needed to round to whole numbers if that's what you want.
  //minimumFractionDigits: 0, // (this suffices for whole numbers, but will print 2500.10 as $2,500.1)
  //maximumFractionDigits: 0, // (causes 2500.99 to be printed as $2,501)
});

formatter.format(2500); /* $2,500.00 */

code from: https://stackoverflow.com/a/16233919/1691542

cc @tannerlinsley

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

1 participant